Jump to content


dynamic page creation

  • Please log in to reply
1 reply to this topic

#1 jbille

  • Members
  • PipPip
  • Member
  • 13 posts

Posted 19 October 2006 - 07:18 PM

I have a page that grabs all products matching the selected category from mysql and outputs them on the page.  I was wondering how I can set these products up as links where when clicked on it will take you to a whole new page which shows that single product.  If anyone could give me an idea on where to start that would be great.  It seems to my I would have to create new php files when the link was clicked on.  Is this correct.

#2 craygo

  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 19 October 2006 - 07:27 PM

Actually you would be better off making a template. Then when the list of products comes up you set a link to to the template with a parameter to grab the product they want to look at.

so your link will go to a page called details.php

you link will look like this.
echo '<a href="details.php?id='.$row['id'].'">';
$row['id'] is the field retrieved from the query

Then on the details page your write a query to retrieve that product

$p_id = $_GET['id'];
$sql = "SELECT * FROM table WHERE id = '$p_id'";

Now you only need one page and the product details are fetched from the query and put in the page.


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users