Hi Guys
I’m from an ASP SQLserver background trying to learn PHP MySQL etc. I have a problem with PHP fOR LOOPS as follows, on my proposed site I have six different catalogues which the user can choose from, there is also the users basket (cart) which is saved for a period of time after the user logs off, in case they return. What I am trying to do is when the user requests a new calalogue is to loop through the ProductID items in the basket and compare it to the ProductID in the catalogue if there is a match set the InBasket column to 1. When the catalogue is displayed a short message is displayed under the catalogue item advising that this item is currently in their basket and also to NOT display the buy button, these goods are not the sort you would want to buy more than one of.
$_SESSION[‘Catalogue’] = array(
‘ProductID’ => $row[‘ProductID’],
‘CatName’ => $row[‘CatName’],
‘DepartmentID’ => $row[‘DepartmentID’],
‘CatPrice’ => $row[‘CatPrice’],
‘CatLocation’ => $row[‘CatLocation’],
‘DepartmentName’ => $row[‘DepartmentName’],
‘Discount’ => $row[‘Discount’],
‘InBasket’ => $row[‘InBasket’]);
$_SESSION[‘CartItems’] = array(
‘BasketID’ => $row[‘BasketID’],
‘ProdName’ => $row[‘ProdName’],
‘ProductID’ => $row[‘ProductID’],
‘Quantity’ => $row[‘Quantity’],
‘ProdPrice’ => $row[‘ProdPrice’],
‘Location’ => $row[‘Location’],
‘Discount’ => $row[‘Discount’],
‘countrytax’ => $row[‘countrytax’]);
for ($i = 0; $i < count($_SESSION[‘CartItems’]); $i++):
{
for ($x = 0; $x < count($_SESSION[‘Catalogue’]); $x++):
{
If ($_SESSION[‘CartItems’][$i][‘ProductID’] == $_SESSION[‘Catalogue’][$x][‘ProductID’])
{
$_SESSION[‘Catalogue’][$x][‘InBasket’] = 1;
}
}
}
The InBasket column never gets updated and yet I am not getting an error on the code!!
Any ideas where I’m going wrong