View Full Version : Linking to a product in the database
purgero
06-10-2009, 05:35 PM
On the home page, I want to link one of the thumbnails to a particular product. I've created a recordset for the "products".
Here is my code...where do I tell it the particular item number?
<a href="/Products_Detail.php?<?php echo $row_rsProducts['ProductID']; ?>=<?php echo $row_rsProducts['ProductID']; ?>"><img src="Images/featured_1.jpg" alt="Placeholder" style="float:left; margin-right:10px;" /></a>
Thanks
Paul
Ray Borduin
06-11-2009, 08:26 AM
It should be:
<a href="/Products_Detail.php?ProductID=<?php echo $row_rsProducts['ProductID']; ?>">
and then you can use $_GET['ProductID'] to reference the product on the product details page.
purgero
06-11-2009, 05:13 PM
Ray,
Can you send me a link to somewhere that I can see exactly how it is done with your extensions?
Thanks
Ray Borduin
06-12-2009, 05:37 AM
This isn't actually done with our extensions. This is just a common php and Dreamweaver concept.
Our extensions don't help you add a url parameter to a link, or to filter a recordset by a url parameter... that is built in DW functionality and a common concept throughout all server languages not just php.
Where do you get stuck? Adding the parameter? Filtering a recordset with the parameter?
purgero
06-12-2009, 06:30 AM
i can get the results page to be linked and come up...but it is how to get the exact product to show in the results page. i guess it is basic stuff.
thanks.
Ray Borduin
06-12-2009, 06:34 AM
Open up the recordset in Simple view
Then choose from the filter dropdown to filter by the url parameter and type in the name of the parameter you are using.
purgero
06-12-2009, 08:01 AM
Ray,
Thanks...when I tested it in Simple view, it showed the correct item. But when the details page opened, it showed no results. Here's the code:
<p><a href="/Products_Detail.php?ProductID=<?php echo $row_rsProducts['ProductID']; ?>"><img src="Images/featured_1.jpg" alt="Placeholder" style="float:left; margin-right:10px;" /></a></p>
Thanks
Ray Borduin
06-12-2009, 08:18 AM
What does the url look like when you click on it in the browser? Does it look correct there? Are you using the same exact parameter name "ProductID" case sensitive?
purgero
06-12-2009, 08:37 AM
When the results show up, or even when I hover over the original link, it shows the following:
Products_Detail.php?ProductID=
So somehow, somewhere, I have the ID in the wrong place.
When I go into the recordset (rsProducts), I have the Products Table, with ALL the columns selected. The filter is: ProductID =, the URL Parameter is 31 (which is the ProductID that I want), and Sort is NONE.
When I test it, it shows fine, but it doesn't come up on the details page, or in the link on the home page.
Thanks
Ray Borduin
06-12-2009, 09:36 AM
That means the problem is with the code linking to the page:
<a href="/Products_Detail.php?ProductID=<?php echo $row_rsProducts['ProductID']; ?>">
specifically:
<?php echo $row_rsProducts['ProductID']; ?>
that column reference or database reference must not be correct....
when it works the url will look like:
Products_Detail.php?ProductID=27
purgero
06-12-2009, 09:57 AM
Ray, where exactly do I tell it which product to show in the results? I want it to show item # 2034. Where do I tell it to show that one?
Ray Borduin
06-12-2009, 10:02 AM
Products_Detail.php?ProductID=2034
purgero
06-12-2009, 10:03 AM
I figured it out.
The productID is 31. I put it in, and it showed up.
<a href="/Products_Detail.php?ProductID=31<?php echo $row_rsProducts['ProductID']; ?>"><img src="Images/featured_1.jpg" border="0" alt="Placeholder" style="float:left; margin-right:10px;" /></a>
Thanks for all your help.
Paul
Ray Borduin
06-12-2009, 10:38 AM
You can get rid of: <?php echo $row_rsProducts['ProductID']; ?>
it is obviously doing nothing.
vBulletin® v3.8.1, Copyright ©2000-2012, Jelsoft Enterprises Ltd.