This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. 按名字取得网址中的query string | |
function getParameterByName(name) { | |
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]"); | |
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), | |
results = regex.exec(location.search); | |
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); | |
} | |
// example | |
// current URL: http: //www.test.com/index.php?name=John |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// 1. 显示当前模板文件的路径 | |
// 1. show template file for page | |
// - put in theme functions.php | |
function ey_which_template_is_loaded() { | |
if ( is_super_admin() ) { | |
global $template; | |
print_r( $template ); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://stackoverflow.com/questions/8082523/export-records-in-excel-file | |
1. Do query in php to get the rows you want to output | |
2. You can use SELECT * FROM table WHERE id IN (1,2,...) | |
3. Use mysql_fetch_array() or mysql_fetch_assoc() to get the rows one at a time | |
4. Use fputcsv() to output them to a file ending in csv - this will properly escape your data | |
Excel will be able to read the file. | |
Override the defaults for fputcsv to use tabs for delimiters and Excel will have an even easier time reading the file. If you use commas (the default) you may need to pick commas as the delimiter on Excel import. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//excel layout | |
<?php | |
header ("Expires: Mon, 28 Oct 2008 05:00:00 GMT"); | |
header ("Last-Modified: " . gmdate("D,d M YH:i:s") . " GMT"); | |
header ("Cache-Control: no-cache, must-revalidate"); | |
header ("Pragma: no-cache"); | |
header ("Content-type: application/vnd.ms-excel"); | |
header ("Content-Disposition: attachment; filename=\"report_".date('dmy_His').".xls" ); | |
header ("Content-Description: Generated Report" ); | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
header("Pragma: public"); | |
header("Expires: 0"); | |
header("Pragma: no-cache"); | |
header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0"); | |
header("Content-Type: application/force-download"); | |
header("Content-Type: application/octet-stream"); | |
header("Content-Type: application/download"); | |
header('Content-disposition: attachment; filename=' . '1006_3d-HK-Flag.png'); | |
header("Content-Transfer-Encoding: binary"); | |
header('Content-Length: ' . filesize(WWW_ROOT.'/feedback_files/1006_3d-HK-Flag.png')); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. click html header -> generate new url with query string including new orderby field name | |
2. php parse query string, handle filed name | |
//html | |
<tr><td align="left" width="10%" class="table_toprow"><div class="orderby" id="job_serial_number"><b>Serial Number</b></div></td> | |
<td align="left" width="10%" class="table_toprow"><div id="invoice_status"><b>Invoice Status</b></div></td> | |
<td align="left" width="20%" class="table_toprow"><div class="orderby" id="job_name"><b>Name</b></div></td> | |
<td align="left" width="10%" class="table_toprow"><div class="orderby" id="job_brand"><b>Brand</b></div></td> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function updateQueryStringParameter(uri, key, value) { | |
var re = new RegExp("([?|&])" + key + "=.*?(&|$)", "i"); | |
separator = uri.indexOf('?') !== -1 ? "&" : "?"; | |
if (uri.match(re)) { | |
return uri.replace(re, '$1' + key + "=" + value + '$2'); | |
} | |
else { | |
return uri + separator + key + "=" + value; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getParameterByName(name) { | |
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]"); | |
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), | |
results = regex.exec(location.search); | |
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//HTML | |
<select id="year_selector" onchange="redirectTo(this)"> | |
<option value="">Select Year</option> | |
<option value="2014">2014</option><option value="2013">2013</option> | |
</select> | |
//Javascript |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// version 1: | |
// param: $birth_date (input string: YYYY-MM-DD) | |
function birthday ($birth_date){ | |
list($year,$month,$day) = explode("-",$birth_date); | |
$today = date('d-m-Y'); | |
$a_birthday = explode('-', $birthday); | |
$a_today = explode('-', $today); | |
$age = $a_today[2] - $year; | |
NewerOlder