Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
|
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 27th, 2005, 05:54 AM
Registered User
 
Join Date: Apr 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Shopping Cart Images

I have been building the shopping cart chapter 14 p 467, and cant figure out the code to include the images for the products i want to appear when viewing the store front.I have lookes through the forums but to no avail. Help!!

echo "<a href = 'getprod.php?prodid=" . $prodnum ."'>";
         echo "THUMBNAIL<br>IMAGE</td></a>";

 
Old April 28th, 2005, 01:53 PM
Registered User
 
Join Date: Apr 2005
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

In reply to your concerns and assuming that you have all of your other code in place where it should be, one thing that I see is that you may be having trouble with your syntax. You may want to try different variations of the code you have and change it to what I have put below...

This is the code you have...

echo "<a href = 'getprod.php?prodid=" . $prodnum ."'>";
         echo "THUMBNAIL<br>IMAGE</td></a>";

You may want to try this...

echo "<a href='getprod.php?prodid=$prodnum'>";
         echo "THUMBNAIL<br>IMAGE</td></a>";

or this...

echo "<a href='getprod.php?prodid="$prodnum"'>";
         echo "THUMBNAIL<br>IMAGE</td></a>";

Hope this helps!

 
Old April 28th, 2005, 02:00 PM
Registered User
 
Join Date: Apr 2005
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Another thing that I have done to help with setting variables is that I set a variable equal to a value, where the value is also a variable. Pay close attention to the variable $prodid, positioned just under $db in the code below.

EXAMPLE...

<?php
    include("connectme.inc");
    $connection = mysql_connect($host,$user,$password)
        or die ("Couldn't connect to server");
    $db = mysql_select_db($database,$connection)
        or die ("Couldn't select database");
    $prodid = "$prodid";
    $query = "SELECT * FROM tblProducts WHERE prodid='$prodid'";
    $result = mysql_query($query)
        or die ("Couldn't execute query")
        //****The rest of your PHP code goes here****//
?>

 
Old April 28th, 2005, 02:06 PM
Registered User
 
Join Date: Apr 2005
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Correction!

I'm sorry. I'm just a beginner at this myself, so please bare with me. I don't think I put the right variable and value.

I believe it should be like this...

<?php
    include("connectme.inc");
    $connection = mysql_connect($host,$user,$password)
        or die ("Couldn't connect to server");
    $db = mysql_select_db($database,$connection)
        or die ("Couldn't select database");
    $prodnum = "$prodnum";
    $query = "SELECT * FROM tblProducts WHERE prodnum='$prodnum'";
    $result = mysql_query($query)
        or die ("Couldn't execute query")
        //****The rest of your PHP code goes here****//
?>

Good Luck!






Similar Threads
Thread Thread Starter Forum Replies Last Post
shopping cart keyvanjan Classic ASP Basics 1 January 9th, 2007 10:16 PM
Shopping cart help rsm42 ASP.NET 1.0 and 1.1 Basics 3 December 9th, 2006 06:09 AM
shopping cart isheikh BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 2 October 8th, 2004 04:20 PM
C# shopping cart franknguyen ASP.NET 1.x and 2.0 Application Design 1 January 5th, 2004 10:54 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.