This code will convert (pivot) your MySQL database table from rows to columns. Here is an example of what this code will do: Original Table ID Name Color 1 James…
$_SERVER[‘REQUEST_URI_PATH’] = parse_url($_SERVER[‘REQUEST_URI’], PHP_URL_PATH); $segments = explode(‘/’, substr($_SERVER[‘REQUEST_URI_PATH’], 1)); Example: If I wanted a different sidebar for the blog directory in this URL: https://jamesnorthard.com/blog/page/2/ I would use the following code:…
The following code will convert the string into a datetime datatype. STR_TO_DATE(datestring, ‘%m/%d/%Y’) To change the format of the date displayed, use DATE_FORMAT. DATE_FORMAT(STR_TO_DATE(datestring, ‘%m/%d/%Y’), ‘%Y-%m-%d’)
This code will display all of the files within a specified directory with a filetype restriction.
Add the following code to the top of your page: And add this code to the bottom of your page:
The code below will export every column name and value from your database into an excel document. Note: Delete the line spaces if you receive a parse error.
// array’s of banned IP addresses $bannedIP = array(“^10.999.00.*”, “^99.88.77.*”, “192.168.0.1”, “^66.77.*.*”); if(in_array($_SERVER[‘REMOTE_ADDR’],$bannedIP)) { // this is for exact matches of IP address in array header(“Location: http://www.domain.com”); exit(); } else…
if ( isset($_SERVER[“REMOTE_ADDR”]) ) { $userip = $_SERVER[“REMOTE_ADDR”]; } else if ( isset($_SERVER[“HTTP_X_FORWARDED_FOR!”]) ) { $userip = $_SERVER[“HTTP_X_FORWARDED_FOR”]; } else if ( isset($_SERVER[“HTTP_CLIENT_IP”]) ) { $userip = $_SERVER[“HTTP_CLIENT_IP”]; } echo…
This code will send exactly two query’s to update a INT (0 or 1) checkbox field in a MySQL database. The IN operational statement let’s you match on a list…
Here is the code required to redirect no host to a www host. PHP and ASP versions of the code are included. PHP ASP