Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

Querying MYSQL with keywords

by storing url string in database

2:40 am on May 7, 2008 (gmt 0)

New User

5+ Year Member

joined:Nov 5, 2007
votes: 0

Hello again Web Master World!

So far in my adventures with PHP/MYSQL i have been structuring sites the following way. I have recently come across the subjects of more in depth normalization and creating indexes. It seems my current approach leaves a bit to be desired in regard to these subjects. I am wondering if anyone might have a better technique to handling this functionality.

On a massive posts table, wouldn't it not be better to create sort posts by an INT id index instead of a possible 200 character string? How much speed could be gained from using a iNT id over a url keyword string?

URL to hit


From the .htaccess file

RewriteEngine on
RewriteRule ^([a-z0-9\-]+)/([a-z0-9\-]+)$ index.php?section=$1&post=$2

General PHP and Mysql

$page_found = false;
$url = $_GET['post'];
$url = addslashes(htmlspecialchars($url));
$query = "
FROM posts
WHERE url = '$url'
AND section = '$section'
$result = $mysqli->query($query) or die ("Error in query: $query. ".$mysqli->error);
$validpage = $result->num_rows;
if ($validpage == 0) {
$app404 = true;
include_once 'errors/404.php';
} else {
$title = "";
while ($row = $result->fetch_array()) {
$id = $row['id'];
$url = $row['url'];
$title = stripslashes($row['title']);
$text = stripslashes($row['text']);
$page_found = true;
if ($title == ""){$page_found = false;}
if ($page_found == true)
echo the post into the template;
echo 404 header and template

As always thanks for any help. I look forward to seeing others approaches to this matter.

[edited by: master_w_bates_III at 2:48 am (utc) on May 7, 2008]