I have a page called foo.php
which is sending URL variable id
to bar.php
like
<?php
echo '<a href="www.domain.com/bar.php?id=1">Comedy</a>';
echo '<a href="www.domain.com/bar.php?id=2">Family</a>';
?>
and in the bar.php
I have
<?php
$id = (int)$_GET['id']
"SELECT * FROM products WHERE id = $id";
?>
which as you can see the result will be presentation of Comedy items or Family items base on the link that user clicked on foo.php
page
now in both case the URL looks very ugly like
www.domain.com/bar.php?id=1
or
www.domain.com/bar.php?id=2
now can you please help me to figure it out how I can use the /comedy
instead of having bar.php?id=1
or /family
instead of bar.php?id=2
?
this looks easy with mod-rewrite
since there are only 2 items here but what if we have many?! is there any dynamic way to take care of this?