hey guys i am a newbie on php programming and right i am trying to setup a cart but the problem is i don't know how to pass the value of the quantity upon clicking the add to cart button.. basically here's the situation:
i have a DB that contains products.
i have a table that shows the contents of the DB.
i have a text input where the customer can put in the quantity of the product.
i am having trouble passing the value of the input text to the cart.php
here is the code:
<?php session_start();?>
<?php
$con = mysql_connect("localhost", "root");
if(!$con){
die('Could not connect;'. mysql_error());
}
mysql_select_db("products", $con);
$query=mysql_query("SELECT * from books");
?>
<form action="cart.php" method="post">
<?php
echo "<table>
<tr align='center'>
<td></td>
<td>Title</td>
<td>Author</td>
<td>Price</td>
<td></td>
</tr>";
while($row= mysql_fetch_array($query)){
echo "<tr align='center'>";
echo "<td><input type=\"text\" name=\"qty\" size=\"3\" maxlength=\"3\"></td>";
echo "<td width='250'>".$row['title']."</td>";
echo "<td width='150'>".$row['author']."</td>";
echo "<td width='150'>".$row['price']."</td>";
echo "<td><input type=\"submit\" name=\"add\" value=\"ADD to cart\"></td>";
}
echo "</table>";
?>
</form>
thanks in advance....