Php Linking To Other Folders

This post will explain how to link images, header and footer files across all folders. For example, let’s say you want to create a subfolder for seo purposes. In this case, let’s create a new folder called new-york. Meanwhile, our files in the root folder had all the css, images and javascript. Since the plan[…]

MYSQL min() Function

The min() function in a mysql query will get the lowest desired value for a given field. The example below will obtain the oldest date between ‘2012-01-02’ and now. <?php include(‘’); $db = public_db_connect(); public_db_connect(); $command = “SELECT min(date) as date FROM table_sort WHERE date < now() AND date > ‘2012-01-01’ “; $result = mysqli_query($db,[…]

PHP trim() Function

The trim() is very useful to remove whitespace before and after any data; thus your strings will be precise characters. The code below shows a form. When the form is submitted, the $_POST variables are escaped and trimmed of any potential whitespace. <?php include(‘’); $db = public_db_connect(); if (count($_POST) > 0) { $firstname = mysqli_real_escape_string($db,[…]

PHP in_array function with mysqli

The following code will grab rows from a table and add the to the $members array. During each loo, the in_array() function checks and makes sure the value from the ‘id’ column is not a duplicate. The ‘continue;’ will restart the loop if a duplicate exists. This is just a demo. In reality, the ‘id’[…]

Combining Arrays With PHP mySQL

Here is a simple example that shows how to combine arrays with data queries from two database tables. <?php include(‘’); $db=public_db_connect(); // names from table #1 $command = “SELECT * FROM table_sort “; $result = mysqli_query($db, $command); while($row = mysqli_fetch_assoc($result)){ $firstname = $row[‘firstname’]; $lastname = $row[‘lastname’]; $array_list[] = $firstname.”-“.$lastname; } // names from table #2[…]

Make Dynamic Page Titles With PHP / mySQL

You can use the variable $page_title in the head section to create the page title within the meta tags. The example is shown below. <?php //get the url of the page with the curl() function $my_url = curl(); $findme = ‘’; $pos = strpos($my_url, $findme); if ($pos == true) { $my_url_trimmed = str_replace(“”, “”, $my_url);[…]