CART Item | Qty 123 | 3 <-- Imagine this is a dropdown and the last value is 5 456 | 4 <-- Imagine last value is already 4. Total: 7
CART Item | Qty 123 | 4 <-- Imagine this is a dropdown and the last value is 5 456 | 4 <-- Imagine last value is already 4. Total: 8
if(isset($_SESSION["products"])) { $total = 0; echo "<form method='post'>"; echo '<table border="1">'; //echo '<th>Item ID</th><th>Item Name</th><th>Category</th><th>Manufacturer</th><th>Model</th><th>Image</th><th>QTY</th><th></th>'; echo '<th>Item Name</th><th>Image</th><th>QTY</th><th></th>'; $concatItems = ""; $itemList = $_SESSION['products']; foreach ($itemList as $cart_itm) { $concatItems .= "'".$cart_itm."',"; $total++; } $items = rtrim($concatItems, ","); $query = "SELECT ItemID, Category, Model, Manufacturer, Item, Image, COUNT(*) As Qty FROM `tblitem` WHERE ItemID in (".$items.") GROUP BY Category, Model, Manufacturer"; $result = mysql_query($query); $count = mysql_num_rows($result); if ($count >= 1){ while ($row = mysql_fetch_assoc($result)) { echo "<tr>"; //echo "<td>" . $row['ItemID'] . "</td>"; //echo "<td>" . $row['Model'] . "</td>"; //echo "<td>" . $row['Category'] . "</td>"; //echo "<td>" . $row['Manufacturer'] . "</td>"; echo "<td>" . $row['Item'] . "</td>"; if ($row['Image'] <> "") { echo "<td><img alt='item' src='".$row['Image']."' style='width: 80px; height: 80px;'></td>"; } else { echo "<td><img alt='item' src='../img/no_image.png' style='width: 80px; height: 80px;'></td>"; } $count = "SELECT * FROM tblitem WHERE Manufacturer='".$row['Manufacturer']."' AND Category='".$row['Category']."' AND Model='".$row['Model']."'"; $queryCount = mysql_query($count); $quantity = mysql_num_rows($queryCount); echo "<td><select>"; for ($h = 1; $h <= $quantity; $h++) { if ($row['Qty'] == $h){ echo "<option value=".$h." selected>".$h."</option>"; } else{ echo "<option value=".$h.">".$h."</option>"; } } echo "</select></form></td>"; echo "<td><a href='cart-actions/remove-item-code.php?id=".$cart_itm."'>Remove</a></td>"; echo "</tr>"; //echo "<tr><td>".$query."</td></tr>"; } } if ($total == '0') { unset($_SESSION['products']); header("Location: view-cart.php"); } echo '</table><br/>'; echo "</form>"; echo 'Total Items: '.$total.'</span><br/>'; echo '<a href="view_cart.php">Check-out</a> || <a href="cart-actions/empty-cart-code.php">Empty Cart</a>'; } else{ echo 'Your Cart is empty'; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)