Jump to content

dynamic page creation


jbille

Recommended Posts

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.
Link to comment
Share on other sites

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.
[code]echo '<a href="details.php?id='.$row['id'].'">';[/code]
$row['id'] is the field retrieved from the query

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

[code]<?php
$p_id = $_GET['id'];
$sql = "SELECT * FROM table WHERE id = '$p_id'";
?>[/code]

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

Ray
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.