wmguk Posted March 19, 2009 Share Posted March 19, 2009 Hey, I've got a function in use function showCart() { global $db; $cart = $_SESSION['cart']; if ($cart) { $items = explode(',',$cart); $contents = array(); foreach ($items as $item) { $contents[$item] = (isset($contents[$item])) ? $contents[$item] + 1 : 1; } $output[] = '<form action="cart.php?action=update" method="post" id="cart">'; $output[] = '<table>'; foreach ($contents as $id=>$qty) { $sql = 'SELECT * FROM products WHERE code = '.$id; $result = $db->query($sql); $row = $result->fetch(); extract($row); $output[] = '<tr>'; $output[] = '<td><a href="cart.php?action=delete&id='.$id.'" class="r">Remove</a></td>'; $output[] = "<td>".$name." Pack Size ".$size."</td>"; $output[] = '<td>£'.$price.'</td>'; $output[] = '<td><input type="text" name="qty'.$id.'" value="'.$qty.'" size="3" maxlength="3" /></td>'; $output[] = '<td>£'.($price * $qty).'</td>'; $total += $price * $qty; $output[] = '</tr>'; } $output[] = '</table>'; $output[] = '<p>Grand total: <strong>£'.$total.'</strong></p>'; $output[] = '<div><button type="submit">Update cart</button></div>'; $output[] = '</form>'; } else { $output[] = '<p>You shopping cart is empty.</p>'; } return join('',$output); } however it doesnt appear to be checking the DB... on this line $output[] = "<td>".$name." Pack Size ".$size."</td>"; all i see is, Pack Size Can anyone point me in the right direction please? Link to comment https://forums.phpfreaks.com/topic/150126-solved-session-and-qry-dont-pull-out-my-cart-info/ Share on other sites More sharing options...
wmguk Posted March 19, 2009 Author Share Posted March 19, 2009 ugh, ok, i missed ' ' so its now working however some of my product id's have & in, ie. OBA0B&B but it only shows OBA0B how can I fix this? Link to comment https://forums.phpfreaks.com/topic/150126-solved-session-and-qry-dont-pull-out-my-cart-info/#findComment-788386 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.