It seems now that I got that one issue fixed it some how fixed another one also. So it seems everything is working great but one thing I would like to do is I have noticed with one of the model numbers I have used for testing “53011” no longer is in the database and when the number is entered it shows nothing in the cart other then the quantity.
Is there a way for me to maybe have a window pop up with a nice message if a number is either typed incorrectly or does not exist in the DB, or perhaps a way that in that case nothing would get put into the cart?
I also have one more minor issue I have noticed. If I build a quote and I type a “0” into the text box for a certain item I may not want, it does take it out of the cart. Where my issue is, is that even though its not in the cart, if I go and hit “Get Quote” It will still be in the list. How would I go about fixing this?
Here is the code I am using.
[code=php]<form name=”cart_quantity” action=”ez_quote.php” method=”POST” style=”display:inline; margin:0px;” autocomplete = “off”>
<?
//This gives you the ability to delete the contents in the cart.
if ($_POST[‘del_x’]){
unset($_SESSION[‘prod_quantity_cart’]);
}
?>
<div class=”bttns”>
<input type=”image” src=”i/update_quote.gif” border=”0″ alt=”Update Totals”>
<A HREF=”quote_sess.php”><IMG src=”i/get_quote.gif” border=”0″></A>
<input type=”image” name=”del” src=”i/clear_quote.gif”>
</div>
<a name=”quote”></a><div class=”h2brdr”><h2>Current Quote</h2></div>
<?php
include (‘ez_db.php’);
//building our session here.
if (!empty($_POST[‘prod_quantity’]) AND !empty($_POST[‘model’])){
$_SESSION[‘prod_quantity_cart’][$_POST[‘model’]] = $_POST[‘prod_quantity’];
} elseif (!empty($_POST[‘cart_quantity’])){
// update qty in cart session after submit
for ($i=0; $i<count($_SESSION[‘prod_quantity_cart’]); $i++){
if ($_POST[‘cart_quantity’][$i] >= 1){
$_SESSION[‘prod_quantity_cart’][$_POST[‘cart_id’][$i]] = $_POST[‘cart_quantity’][$i];
} else {
$_SESSION[‘prod_quantity_cart’][$_POST[‘cart_id’][$i]] = ”;
unset($_SESSION[‘prod_quantity_cart’][$_POST[‘cart_id’][$i]]);
}
}
}
//This will connect to the database and grab the data that we need and display everything accordingly.
if (is_array($_SESSION[‘prod_quantity_cart’])){
echo “<table width=”600″ border=”0″ cellspacing=”0″ align=”center”>”;
foreach ($_SESSION[‘prod_quantity_cart’] AS $prod=>$qty){
$sql = mysql_query(“SELECT * FROM product WHERE model=’$prod'”);
$row = mysql_fetch_array($sql);
$_SESSION[‘prod_quantity’][$row[‘id’]] = $qty;
echo <<< TBL
<tr><td class=”plinky”><img src=”i/t.gif” alt=”” height=”1″ width=”52″></td>
<td width=”71″ align=”center” class=”plinky”><a href=”p.php?n={$row[‘id’]}” target=”_blank” onclick=”javascript:op(‘p.php?n={$row[‘id’]}’); return false”>{$row[‘model’]}</a></td>
<td width=”329″ align=”center”>{$row[‘little_desc’]}</td>
<td align=”center” class=”plinky”><input type=”text” name=”cart_quantity[]” value=”$qty” style=”width: 40px;” size=”5″ maxlength=”5″ class=”plinky”>
<input type=”hidden” name=”cart_id[]” value=”$prod”></td>
</tr>
TBL;
}
echo “</table>”;
}
?>
<table style=”table-layout:fixed” width=”597″ height=”20″ border=”0″ align=”center” cellspacing=”0″>
<tr>
<td align=”right” width=”105″ class=”plinky”><strong>Model #:</strong></td>
<td class=”plinky” align=”center” width=”70″><input name=”model” style=”width: 40px;” size=”20″ maxlength=”20″ class=”plinky” value=”” type=”text”></td>
<td colspan=”2″ width=”416″ align=”left” class=”plinky”><strong>Quantity:</strong>
<input name=”prod_quantity” size=”2″ maxlength=”4″ class=”plinky” type=”text” style=”width: 40px”>
</td>
</tr></table>
</form>
Any Ideas?
Thank you