Array Of SQL Results

Creating An Array Of All Results $all_results = array(); //Empty array to hold returned rows while ($row = @mysql_fetch_array($search_query)) { $all_results[] = $row; }      

Read More

DateTime general

ORDER BY Date Order ASC = oldest first DESC = most recent first Note it’s “MINUTE”, “HOUR”, etc not “MINUTES” or “HOURS” etc Convert DateTime to Date Specifying Date and DateTime from a string It is recommended to use CAST() Last Day Of Month (This produces a DATE result, not DATETIME) Get SQL Server’s Current […]

Read More

TextArea

Note – for single line test use <input type=”text” not textarea! Max length Background text Text that vanished when you start typing into the box

Read More

Global Variables & Defines

Variables Any variable used inside a function is by default limited to the local function scope. If you want to access a variable used outside of the function you need to declare it as global within the function: Defines No need to declare a define as global in functions, any function can simply use it

Read More

Using Strings-Formatting

Text Formatting Trim leading and trailing whitespace Capitalise 1st letter of first word Capitalise 1st letter of every word (but leave capitalised words like “ABC” as they are) String to lowercase String to uppercase Convert \n character to <br> when displaying as normal php text

Read More

Detecting Name Of Page Include A File

//include_once('includes/my_include_file.php'); //Get the name of the file calling this include $calling_file = end(explode('/', $_SERVER[‘PHP_SELF’])); switch ($calling_file) { case 'some_file.php':

Read More