can you add a php variable in to a mysql script?

  • Thread starter Thread starter adam
  • Start date Start date
A

adam

Guest
cart is the name of the table and i have dropdown boxes on the previous page POSTING the results name, size, color, and quantity.

here is the entire page of script:

<?php

$name=$_POST["name"];
$size=$_POST["size"];
$color=$_POST["color"];
$quantity=$_POST["quantity"];

mysql_connect("fdb1.awardspace.com", "username", "password") or die(mysql_error());
mysql_select_db("mydatabase") or die(mysql_error());


THIS IS THE PART:
mysql_query("INSERT INTO cart
(name, size, color, quantity) VALUES('$name', '$size', '$color', '$quantity' ) ")
or die(mysql_error());

$result = mysql_query("SELECT * FROM cart")
or die(mysql_error());

$row = mysql_fetch_array( $result );

AND THIS IS WHERE THAT PART SPITS OUT THE INFO... as you should know:
echo "Name: ".$row['name'];
echo "Size: ".$row['size'];
echo "Color: ".$row['color'];
echo "Quantity: ".$row['quantity'];

?>
 
Back
Top