Hi, Im building a cart everything is sweet but i need to be able to add values returned from a mysql query in a while loop.
if($id and $si and $quan)
{
// adds extra item to arrays
$purchase[] = $id;
$size[] = $si;
// queries arrays and returns the values
for ($i = 0; $i < count($size); $i++)
{
// connects to db and queries info required for each value in arrays.
$link_id = db_connect("iiwii");
$query = "select * from gallery where id='$purchase[$i]'";
$result = mysql_query($query);
while($myrow = mysql_fetch_row($result))
{
// sets variables for mysql results returned
$product = $myrow[2];
$desc = $myrow[3];
$price = $myrow[4];
}
echo "<tr><td>$product</td>
<td>$desc</td>
<td>$size[$i]</td>
<td><select size=\"1\" name=\"quan\">
<option>$quantity</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select></form></td>
<td>£$price</td></tr>";
}
}
Ok so it all works... it returns the info I want from the database and lists them all into new rows on the cart.
If there is only one item my cart works perfectly coz everything is the same price. But usually there is more than one item so what I need to do is add the $price variable to itself for each record returned. I should imagine the $price returned should be added into another array and then the values totaled to return the total value.
Please help!!!