Forum Moderators: coopster
<html>
<head>
<title> ..::Welcome to Car Shop::..</title>
</head>
<body>
<?php
mysql_connect("localhost", "root","") or die(mysql_error());
// echo "Connected to MySQL<br />";
mysql_select_db("db_shoppingcart") or die(mysql_error());
// echo "Connected to Database";
$result = mysql_query("SELECT * FROM tbl_items WHERE stock!='0';")
or die(mysql_error());
echo "<form action='preview.php' method='post'>";
echo "<table border='1' align='center' cellpadding='10'>";
echo "<tr><th colspan='8' align='center'>!Select Your Cars Here!</th></tr>";
echo "<tr> <th>Name</th> <th>Type</th> <th>Make</th> <th>Price</th> <th>Stock</th> <th>Select Quantity</th> <th>Click Here</th></tr>";
while($row = mysql_fetch_array( $result ))
{
echo "<tr><td align='center'>";
echo $row['Name'];
echo "</td><td align='center'>";
echo $row['Type'];
echo "</td><td align='center'>";
echo $row['Make'];
echo "</td><td align='center'>";
echo $row['Price'];
echo "</td><td align='center'>";
echo $row['Stock'];
echo "</td>";
echo "<td align='center'><select name='qty[]'>";
for($i=0;$i<=$row['Stock'];$i++)
{
echo "<option value=".$i.">".$i."</option>";
}
echo "</select></td><td align='center'><input type='checkbox' name=".$row['Name']." value=".$row['Name'].">";
echo "</td></tr>";
}
echo "<tr><td colspan='7' align='center'><input type='submit' name='submit' value='Preview!'></td></tr>";
echo "</table>";
echo "</form>";
?>
</body>
</html>
after submitting the form.....the user should be able to preview what he has selected and then should checkout,after which the user would be displayed the page where he has the total no. of items he has selected with their types and total cost.
Can anyone lend a helping hand?
>> the user should be able to preview what he has selected and then should checkout
what exactly are you looking for help with?
the preview page?
the checkout process?
what code do you have so far for those components?
is there a specific piece of code that is giving you a problem?
</head>
<body>
<?php
mysql_connect("localhost", "root","") or die(mysql_error());
// echo "Connected to MySQL<br />";
mysql_select_db("db_shoppingcart") or die(mysql_error());
// echo "Connected to Database";
$item=$_POST["qty"];
$car=$_POST['check1'];
// print_r($car);
// echo $car;
echo "Order Processed";
echo "<br>";
echo "<br>";
$z = implode (",", $item);
print $z;
echo "<br>";
echo "<br>";
// echo "<pre>";
// print_r($item);
// echo "</pre>";
//echo "You have selected total"." ".array_sum($item)." "."car(s).";
echo "Selected Cars";
echo "<br>";
echo "<br>";
$a = implode (",", $car);
print $a;
// echo "<pre>";
// print_r($car);
// echo "</pre>";
$result = mysql_query("SELECT Name,Price FROM tbl_items WHERE Id='$a';")
or die(mysql_error());
echo "<br>";
echo "<br>";
echo "You have selected"." ".$a." ";
echo "<table>";
while($row = mysql_fetch_array( $result ))
{
echo "<tr><td align='center'>";
echo $row['Name'];
echo "</td>";
echo "<td align='center'>";
echo $row['Price'];
echo "</td></tr>";
}
// echo "<br>";
// echo "<br>";
echo "</table>";
?>
</body>
</html>