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
https://forums.phpfreaks.com/topic/24472-dynamic-page-creation/
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
https://forums.phpfreaks.com/topic/24472-dynamic-page-creation/#findComment-111489
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.