I look at some sites that pretend that there is a directory structure in the URL and are wondering how.
I take charge of managing the website at work and review the code. They have a database for all pages, and they are created dynamically.
I can make the home page work on my local server, but I don’t know where to start with a fake directory structure. Example: http://www.bankcharges.com/bank-charges-advice/- there is no directory for this, but the content is in the database.
How did they do it?
The code I'm thinking of is related to:
index.php:
<?php
include('includes/functions.php');
$activeTab = "navhome";
$sent = false;
$title = (isset($_GET['title']))? mysql_real_escape_string($_GET['title']) : 'Home';
$title = str_replace('-',' ', $title);
if($title != '') {
$sql = "SELECT *
FROM contents
WHERE name LIKE '%$title%'
LIMIT 1";
$result = @mysql_query($sql);
$row = mysql_fetch_assoc($result);
}
$pagetitle = (isset($row['name']) && $title != 'Home')? ucwords($row['name']) : "Bank Charges";
?>
functions.php:
<?php
include('database.php');
include('settings.php');
function url($str){
$arr = array('!','"','£','$','%','^','&','*','(',')','_','+','{','}',':','@','~','<','>','?','|',',','.','\\','/',';',']','[','\'');
$str = str_replace($arr,"", str_replace(" ","-",strtolower($str)));
return $str;
}
function isEven($v){
if($v % 2 == 0) return true;
}
?>