Forum Moderators: open

Message Too Old, No Replies

Php & SQL data retrieval

Problems trying to get data from sql db using php

         

jeng3011

12:50 pm on Jan 28, 2009 (gmt 0)

10+ Year Member



Hi

I have a webpage which shows a list of products pulled from a table on an sql db.
What I need to be able to do is click on each product and bring up info about each product retrieved from the sql db.

eg. Prod1, Prod2, Prod3 is the list on my page

When I click on Prod1 I want it to go to a new page and show me info about that product. This info is already on the sql db.
Is a href command I have to use?

Any help would be appreciated

Thanks

physics

4:24 pm on Jan 28, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You need to create a link that includes the unique key for each product. Clicking the link will either reload the current PHP page with new parameters or go to a new php page. So the link might look like /page.php?prodid=Prod2
There must be PHP code in the page that keys off of that parameter and then extracts the desired information from the database and displays it.

What code are you using to display the product list? You should be able to use that as a guide to accomplish this.

jeng3011

9:49 am on Jan 29, 2009 (gmt 0)

10+ Year Member



the code i have in my main page is
<td class="main" width="50%"><a href="newtestjen.php?prodid=ProdType1"><?php echo $row['ProdType']; ?></a></td>

this pages displays 3 links, prod1, prod2, prod3

when i click on each link they open newtestjen.php and i have code in that page saying
$prodid = $_GET["ProdType"];
what i need is code to say if prod1 is clicked on then show me the username for prod1 for example and the same for prod2 and prod3

does that make sense?