0

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?

Behseini
  • 5,416
  • 18
  • 60
  • 107
  • Comments are not for extended discussion; this conversation has been [moved to chat](http://chat.stackoverflow.com/rooms/96095/discussion-on-question-by-behseini-url-rewriting-for-dynamic-pages-based-on-url). – elixenide Nov 25 '15 at 01:38
  • @EdCottrell making use of the new super powers already i see, its ok i voted for you. –  Nov 25 '15 at 02:17
  • This is still not working! – Behseini Nov 25 '15 at 16:17

0 Answers0