hi
i am doing shopping online, i will let user choose their prodcut in the first page and then when they click" order" button, they will be redirected to do_addcart.php. i will insert their orders into "orders" table and retrieve them back and ask user to select their respective quantity and size. i have used Javascript validation:
the code is below:
[CODE=javascript] <script language="JavaS cript">
<!--
function validate_form ( )
{
valid = true;
alert (document.Lform .quantity.selec tedIndex);
if ( document.Lform. quantity.select edIndex == 0 )
{
alert ( "Please select your quantity!" );
Lform.quantity. focus();
valid = false;
}
else if ( document.Lform. size.selectedIn dex == 0 )
{
alert ( "Please select your size!" );
Lform.size.focu s();
valid = false;
}
return valid;
}
//-->
</script>[/CODE]
However, i don;t know how to correspond respective product with their respective choosen quantity and size.
the following is my current coding,
[CODE=php] <?php
foreach ($_POST as $key => $value) {
echo "key: ".$key.", value: ".$value."<br>" ;
$sql = "INSERT INTO orders (imageid, userid, time) VALUES ('$key', '$userid', '$date')";
mysql_query($sq l);
}
echo "Please select your size and quantity for purchase:";
echo "<table border = '1'>";
echo "<tr>";
echo "<td>Title";
echo "<td>Brand";
echo "<td>Price";
echo "<td>Size";
echo "<td>Quantity";
echo "</tr>";
$sql2="SELECT imageid FROM orders";
$result=mysql_q uery($sql2);
while($row = mysql_fetch_arr ay($result)) {
echo "<br>";
$sql3="SELECT brand, price, title FROM ladies WHERE id=".$row['imageid'];
$ImageResult = mysql_query($sq l3);
$ImageDetail = mysql_fetch_arr ay($ImageResult );
echo "<tr>";
echo "<td>".$ImageDe tail['title']."";
echo "<td>".$ImageDe tail['brand']."";
echo "<td>".$ImageDe tail['price']."";
echo"<td>";
echo"
<select id='size' name='size' tabindex='11'>
<option value='0'>---
<option value='1' >S
<option value='2'>M
<option value='3'>L
<option value='4'>XL
</select>
</td>";
//echo" ";
echo"
<td>
<select id='NO' name='quantity' tabindex='11'>
<option value='0'>---
<option value='1' >1
<option value='2'>2
<option value='3'>3
<option value='4'>4
<option value='5'>5
<option value='6'>6
<option value='7'>7
<option value='8'>8
<option value='9'>9
<option value='10'>10
</select>
</td>";
echo "</tr>";
}
echo "</table>";
echo "<input type = 'submit' value = 'order'>";
?>[/CODE]
anyone can help me with this, thank you very much. it is bit urgent as the project deadline is near.
i am doing shopping online, i will let user choose their prodcut in the first page and then when they click" order" button, they will be redirected to do_addcart.php. i will insert their orders into "orders" table and retrieve them back and ask user to select their respective quantity and size. i have used Javascript validation:
the code is below:
[CODE=javascript] <script language="JavaS cript">
<!--
function validate_form ( )
{
valid = true;
alert (document.Lform .quantity.selec tedIndex);
if ( document.Lform. quantity.select edIndex == 0 )
{
alert ( "Please select your quantity!" );
Lform.quantity. focus();
valid = false;
}
else if ( document.Lform. size.selectedIn dex == 0 )
{
alert ( "Please select your size!" );
Lform.size.focu s();
valid = false;
}
return valid;
}
//-->
</script>[/CODE]
However, i don;t know how to correspond respective product with their respective choosen quantity and size.
the following is my current coding,
[CODE=php] <?php
foreach ($_POST as $key => $value) {
echo "key: ".$key.", value: ".$value."<br>" ;
$sql = "INSERT INTO orders (imageid, userid, time) VALUES ('$key', '$userid', '$date')";
mysql_query($sq l);
}
echo "Please select your size and quantity for purchase:";
echo "<table border = '1'>";
echo "<tr>";
echo "<td>Title";
echo "<td>Brand";
echo "<td>Price";
echo "<td>Size";
echo "<td>Quantity";
echo "</tr>";
$sql2="SELECT imageid FROM orders";
$result=mysql_q uery($sql2);
while($row = mysql_fetch_arr ay($result)) {
echo "<br>";
$sql3="SELECT brand, price, title FROM ladies WHERE id=".$row['imageid'];
$ImageResult = mysql_query($sq l3);
$ImageDetail = mysql_fetch_arr ay($ImageResult );
echo "<tr>";
echo "<td>".$ImageDe tail['title']."";
echo "<td>".$ImageDe tail['brand']."";
echo "<td>".$ImageDe tail['price']."";
echo"<td>";
echo"
<select id='size' name='size' tabindex='11'>
<option value='0'>---
<option value='1' >S
<option value='2'>M
<option value='3'>L
<option value='4'>XL
</select>
</td>";
//echo" ";
echo"
<td>
<select id='NO' name='quantity' tabindex='11'>
<option value='0'>---
<option value='1' >1
<option value='2'>2
<option value='3'>3
<option value='4'>4
<option value='5'>5
<option value='6'>6
<option value='7'>7
<option value='8'>8
<option value='9'>9
<option value='10'>10
</select>
</td>";
echo "</tr>";
}
echo "</table>";
echo "<input type = 'submit' value = 'order'>";
?>[/CODE]
anyone can help me with this, thank you very much. it is bit urgent as the project deadline is near.
Originally posted by Ajaxrand
Comment