OK, having another bit of trouble however some progress has been made.
We are getting the item id and checking it against the item_id in the colour table, this is fine, but when we actually choose the colour id we are wrong.
We choose the colour id which matched the item id and also matches with the colours itemid. I think this has explained it better?? if not i'll post some code below..
mysql_query("insert into tblstore_items values ('1', '1', 'Easter Egg Selection',5.99, 'Which chocolate most tickles your fancy this easter?','images/easter/newsletter_easter.jpg')");
mysql_query("insert into tblstore_items values ('2', '1', 'Chocolate Bunny',4.99, 'Give this gorgeous bunny to a loved one this easter.','images/easter/EasterBunny.jpg')");
mysql_query("insert into tblstore_items values ('3', '1', 'Easter Candle Pack',10.99, 'Light up your life this easter with some scented candles.','images/easter/eastdisp.jpg')");
mysql_query("insert into tblstore_items values ('4', '1', 'Chocolate Surprise Egg',3.99, 'Open wide for more chocolate this easter','images/easter/surpriseegg.jpg')");
mysql_query("insert into tblstore_items values ('5', '2', 'Red Rose',4.99,'Single Red Rose', 'images/valentines/bunches.jpg')");
mysql_query("insert into tblstore_items values ('6', '2', 'Love Heart Necklace',25.99,'Gorgeous Necklace any girl would be delighted with.','images/valentines/diamondnecklace.jpg')");
mysql_query("insert into tblstore_items values ('7', '2', 'Rose Petals',7.99,'Make someone feel special with this bag of Rose Petals.', 'images/valentines/rosepetals.jpg')");
mysql_query("insert into tblstore_items values ('8', '2', 'Champagne & Truffles',40.99,'Moet & Chandon Champagne & Chocolate Truffles', 'images/valentines/champagne&truffles.jpg')");
mysql_query("insert into tblstore_colour values ('1', '3', 'Yellow')");
mysql_query("insert into tblstore_colour values ('2', '3', 'White')");
mysql_query("insert into tblstore_colour values ('3', '3', 'Mixed')");
mysql_query("insert into tblstore_colour values ('4', '2', 'Gold')");
mysql_query("insert into tblstore_colour values ('5', '2', 'Silver')");
mysql_query("insert into tblstore_colour values ('6', '6', 'Gold')");
mysql_query("insert into tblstore_colour values ('7', '6', 'Silver')");
for($i = 0; $i < count($_SESSION['basket']); $i++)
{
$product = $_SESSION['basket'][$i];
$myarray = explode('|', $product);
$get_cart = "SELECT c.id AS cat_id, c.cat_title, si.id, si.item_title, si.item_price, si.item_desc, si.item_image FROM tblstore_items AS si LEFT JOIN tblstore_categories AS c ON c.id = si.cat_id WHERE si.id = $myarray[0]";
$get_cart_res = mysql_query($get_cart,$conn);
while($row = mysql_fetch_array($get_cart_res))
{
$item_id = $row['id'];
$item_title = $row['item_title'];
$item_price = $row['item_price'];
}
$unit_price = sprintf("%.02f", $item_price * $myarray[1]);
$total_price += $unit_price;
$get_color = "SELECT * FROM tblstore_colour, tblstore_items WHERE tblstore_colour.item_id = tblstore_items.id AND tblstore_colour.id = {$myarray[0]}";
$colour="";
$get_color_results = mysql_query($get_color,$conn);
if ($get_color_results!==FALSE)
{ // or else, add an " or die("failed to execute '$get_color' : ".mysql_error());" to the mysql_query() call above...
if ($row_colour=mysql_fetch_array($get_color_results)) {
$colour = $row_colour['item_colour'];
$colours = ($colour=="") ? " " : $colour;
}
else {
$colours=' '; // if failed to execute query on colours
}
}
$display_block2 .= "
<tr>
<td class=border align=center>$item_title</td>
<td class=border align = center>$size</td>
<td class=border align = center>$colours</td>
<td class=border align = center>£ $item_price</td>
<td class=border align = center>$myarray[1]</td>
<td class=border align = center>£ $unit_price</td>
<td class=border align = center><a href='removefromcart.php?id=$item_id'>Remove</a></td>
</tr>";
}
$display_block2 .= "</table>
<input name = 'total_prices' type = 'hidden' value = '$total_price'>
<p align = 'center'>Basket Total: £". $total_price. "<br><br>
<input type = 'submit' name = 'checkout' value = 'Go to Checkout'></p>
</form>";
}
?>