Hi Jennifer,
Okay first, in your current page, just do one SQL statement that selects the
4 fields you want all at once, then use extract() to turn the record/result
into variables, and print out your form like:

// Query
$ret = mysql_query(
"SELECT id, image, name, quantity, price FROM items WHERE id = 1"

// Check for Error First
if(mysql_num_rows > 0)
        print "<form action='buyitem.php' method='post'>";

        // Get Record and Echo/Print Out Data
        while($rec = mysql_fetch_assoc($ret))
                echo "<input type='image' src='images/blueholo.gif'><br>";

                echo "<b>$name</b><br>";
                echo "Quantity $quantity<br>";
                echo "Cost: $price SC<br>";
                echo "<input type='hidden' name='ItemID' value='$id'>";

        print "</form>";
        // Say there's a problem and echo the error message to an HTML
        print "There was a problem while fetching the item from the
        print "<!-- " . mysql_error() . " -->\n";

... Now you'll have a file that will post a field called ItemID containing
the ID number (in this case, 1) to buyitem.php. Now you just code
buyitem.php to add the product to the user's "basket". There are several
ways of doing that, but this should be the proper stepping stone.

- Jonathan

PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to