Welcome To Snipplr
Everyone's Recent PHP Snippets
- All /
- JavaScript /
- HTML /
- PHP /
- CSS /
- Ruby /
- Objective C
# Export MySQL Data as CSV
This code takes a `mysql_query()` resource and outputs its rows into CSV spreadsheet format. Edit the `header('Content-Disposition...` declaration to tell the user's browser to either display the data as plain text or do...
6
1015
posted 15 years ago by mikegreen
This is for a particular search on a project. Just saving here for future use.
0
641
posted 15 years ago by joeymarchy
Better way to echo a .current_page_item class on a list nav.
3
781
posted 15 years ago by davebowker
Checks for a valid email address using the php-email-address-validation class.
Source and docs = URL
0
752
posted 15 years ago by fruehjahr
Forces a user to download a file, for e.g you have an image but you want the user to download it instead of displaying it in his browser.
0
745
posted 15 years ago by fruehjahr
Based on Jdub7's Pure PHP Template function
http://snipplr.com/view/10797/pure-php-template-function/
2
748
posted 15 years ago by thermosilla
Return just the Apache version number of your server, and operating system, from $_SERVER['SERVER_SOFTWARE']
Example:
print ('Apache Version: ' . apacheversion());
will return something along the lines of...
"Apache Version: 2.2.10 (Unix...
1
1754
posted 15 years ago by iridium
Simple but useful function for getting a single piece of data from a database and placing it straight into a variable.
Example:
$variable = one_result("SELECT columnOne FROM table WHERE columnTwo=whatever");
This would insert the value of colu...
1
621
posted 15 years ago by iridium
Usage:
define('PIRATE',bindec('0001')); // 1
define('NINJA',bindec('0010')); // 2
define('JEDI',bindec('0100')); // 4
define('ADMIN',bindec('1000')); // 8
$rpermit = array(PIRATE,JEDI); // Equivilent Flags '0101'...
0
497
posted 15 years ago by Jdub7