PHP

Loading Indicator

Loading Indicator PHP Function (with JS and CSS)

Creating a Loading Indicator with PHP, JavaScript, and CSS A loading indicator is a visual cue that informs users that a process is underway, enhancing user experience by providing feedback during wait times. This snippet demonstrates how to create one using PHP, JavaScript, and CSS. This handy function wraps some HTML, CSS, and JS to create a pulsing circle and

Loading Indicator PHP Function (with JS and CSS) Read More »

PHP Current Directory

How to get current directory, filename and code line number in PHP

Clarity TLDR: Use __DIR__ for the current script’s directory, basename(__FILE__) for the current filename, and __LINE__ for the current line number. The older dirname(__FILE__) form still works, but __DIR__ is the modern equivalent. Examples of each below. In PHP, there are several built-in functions that can be used to obtain information about the current script’s

How to get current directory, filename and code line number in PHP Read More »

Loop Through PHP Request Values – GET and POST

Loop through PHP Request Values In order to Loop through PHP Request Values – GET and POST without knowing what they all might be, you can simply use the following code: foreach ($_REQUEST as $key => $value) { $value = mysql_real_escape_string( $value ); $value = addslashes($value); $value = strip_tags($value); if($value != “”){$requestnumber ++;} echo $key.

Loop Through PHP Request Values – GET and POST Read More »

Encode Mysql Results to JSON

The title says it all: mysql_set_charset(‘utf8’, $database_connection); // charset $sqlStr = “SELECT * FROM yourtable;”; //provide the query $result = mysql_query ($sqlStr, $database_connection) or die ($sqlStr); // get the results $rows = array(); // create the array if (mysql_num_rows($result)) { while ($row = mysql_fetch_assoc($result)) { // populate array with results $rows[] = $row; } }

Encode Mysql Results to JSON Read More »