php购买页面,没有传递值添加到购物车页面。我如何传递这些值?

时间:2014-11-22 16:35:58

标签: php html mysql

我是php的新手,仍然在为我的项目苦苦挣扎。我无法传递产品的价值 选择到addcart页面。你能看到我所缺少的东西,我觉得我变得如此接近。

产品页面:

$display6="SELECT * 
    FROM in_product LIMIT $start, $pagerows; " ; 
$displayResult6 = @mysqli_query($dbhandle, $display6)
            or die(mysqli_error($dbhandle));

while($row6 = mysqli_fetch_array($displayResult6, MYSQLI_ASSOC)) {  
$i = 1;
$x = $row6['ip_stock'];
$y = " ";
for($i = 1; $i <= $x; $i++) {
$y .= "<option value=' . $i . '> $i </option>";
 }            
echo "<tr>
<form action='addcartInstate.php' method='post' name='addtocartForm' id='addtocartForm' >
<input type='hidden' id='prod' value='" . $row6['ip_id'] . "' /></td>
<td class='td2'><input type='submit' name='submit' value='Add to Cart' /></td>
<td class='td2'><strong> " . $row6['ip_name'] . " </strong><br> " . $row6['ip_desc'] . " <br> $" . $row6['ip_price'] . " </td>
<td class='td2'><img alt='first' src=" . $row6['ip_image'] . " width='300' height='250'></td>
 <td class='td2'><br>
     <b>Quantity:&nbsp;&nbsp;</b><br>
            <select id='orderIn_quantity' name='orderIn_quantity'>
                <option value='Select'> Select </option> 
                " . $y . "                                              
            </select>
 </td>
 </form>
</tr>";

}     echo&#34;&#34;;

添加到购物车页面:

if(isset($_GET['ip_id'])) {
        $ip_id = $_GET['ip_id'];
        } elseif (isset($_POST['ip_id'])) {
        $ip_id = $_POST['ip_id'];
        }

    if(isset($_POST['orderIn_quantity'])) {
        $orderIn_quantity = $_POST['orderIn_quantity'];
        }

$display="SELECT * 
    FROM in_product WHERE ip_id = '$ip_id'; " ; 
$displayResult = @mysqli_query($dbhandle, $display)
            or die (mysqli_error($dbhandle));

$row = mysqli_fetch_array($displayResult);          
$orderIn_total = $row['ip_price'] * $orderIn_quantity; 

$orderIn_complete = "No";

$insert = "INSERT INTO order_instate(user_id, ip_id, orderIn_quantity, orderIn_total, orderIn_complete )
                VALUES ('$user_id', '$ip_id', '$orderIn_quantity', '$orderIn_total', '$orderIn_complete' )"; 

        $addInsert=mysqli_query($dbhandle, $insert)
                        or die(mysqli_error($dbhandle)); 

        if ($addInsert != NULL) {
            echo "<h3>This product has been added to your shopping cart. </h3>";
        }

&GT;

0 个答案:

没有答案