The code I have below makes links such as "site.com/image.php?id=12", but does anyone have any tips on making it make links such as "site.com/image/12" or something similar, without manually making a page for each individual id?
$result = mysqli_query($con,"SELECT * FROM tabl1 where name like '%$s%'");
while($row = mysqli_fetch_array($result))
{
echo "<a href='image.php?id=" . $row['id'] . "'>" . $row['Name'] . "</a>";
echo "<br>";
}
I have code on the image.php page that looks something like
$result = mysqli_query($con,"SELECT * FROM celeb where id like '$id'");
that uses the id from the ?id=12 part on my website, so I'm not sure how that would work if I did change it to clean urls.
Any help would be useful, I am kind of a newbie to php here.
EDIT:
RewriteEngine On
RewriteRule ^image/id/([^/]*)\.php$ /image.php?id=$1 [L]
I created a .htaccess file and put that in it, yet when I click on the link it still goes to image.php?id=12 Am I doing something wrong? Is there anything else I must do?
This site does the work for you http://www.generateit.net/mod-rewrite/
The original URL:
http://site.com/image.php?id=12
The rewritten URL:
http://site.com/image/12
htaccess:
RewriteEngine On
RewriteRule ^image/([^/]*)$ /image.php?id=$1 [L]