I'm using following code to pass number values to my shopping cart cord.
if(is_array($_SESSION['cart'])){
echo '<tr bgcolor="#FFFFFF" style="font-weight:bold">
<td>Serial</td>
<td>Part No</td>
<td>Name</td>
<td>Price</td>
<td>Qty</td>
<td>Amount</td>
<td>Options</td>
</tr>';
$max=count($_SESSION['cart']);
for($i=0;$i<$max;$i++){
$pid=$_SESSION['cart'][$i]['productid'];
$q=$_SESSION['cart'][$i]['qty'];
$pname=get_product_name($pid);
if($q==0) continue;
?>
<tr bgcolor="#FFFFFF">
<td><?php echo $i+1 ?></td>
<td><?php echo $pid ?></td>
<td><?php echo $pname ?></td>
<td>$ <?php echo get_price($pid)?></td>
<td><input type="text" name="product<?php echo $pid?>" value="<?php echo $q?>" maxlength="3" size="2" /></td>
<td>$ <?php echo get_price($pid)*$q?></td>
<td><a href="javascript:del(<? echo $pid?>)">Remove</a></td>
</tr>
<?php
}
?>
when I'm inserting number values like "12191008" , "05191034" it's working fine. but for the string values like "PF401404" its not working. how can I modify the code to pass string values ?
also add to cart function as follows..
function addtocart($pid,$q){
if($pid<1 or $q<1) return;
if(is_array($_SESSION['cart'])){
if(product_exists($pid)) return;
$max=count($_SESSION['cart']);
$_SESSION['cart'][$max]['productid']=$pid;
$_SESSION['cart'][$max]['qty']=$q;
}
else{
$_SESSION['cart']=array();
$_SESSION['cart'][0]['productid']=$pid;
$_SESSION['cart'][0]['qty']=$q;
}
}
i think
if($pid<1 or $q<1) return;
this is not working for you. Because your $pid is not an integer in your case