4 php mysql directory structure
我一直在看一些网站假装网址中有一个目录结构,并想知道'如何?'.
我正在控制工作中的网站,并查看了代码.他们有一个所有页面的数据库,它们是动态创建的.
我可以让我的本地服务器上的主页工作,但我不知道从哪里开始假的目录结构.一个例子是http://www.bankcharges.com/bank-charges-advice/- 没有目录,但内容在数据库中.
他们是怎么做到的?
我认为与此相关的代码是:
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);
}
//Set page title
$pagetitle = (isset($row['name']) && $title != 'Home')? ucwords($row['name']) : "Bank Charges";
?>
Run Code Online (Sandbox Code Playgroud)
functions.php:
<?php
include('database.php');
include('settings.php');
//Nice URL's
function url($str){
$arr = array('!','"','£','$','%','^','&','*','(',')','_','+','{','}',':','@','~','<','>','?','|',',','.','\\','/',';',']','[','\'');
$str = str_replace($arr,"", str_replace(" ","-",strtolower($str)));
return $str;
}
function isEven($v){
if($v % 2 == 0) return true;
}
?>
Run Code Online (Sandbox Code Playgroud)