[thelist] MySQL SELECT and INSERT not following (my) logic

Andrew Maynes andrew at humanbehaviour.co.uk
Wed Feb 12 10:00:03 CST 2003


I have the follow MySQL queries for pulling out ans then inserting a record from
a record set.  Unfortunately I think I have missed something (vital) as the
record being inserted is the value and not the name, for example 1 instead of
blue... can someone kindly have a look and spot where I have gone wrong?


records pulled:

function showColor($item_id)
{
 $query="select ref_colours.* from item_color ,ref_colours where
ref_colours.ColorID=item_color.color_id and item_color.item_id=$item_id";
$rs=mysql_query($query);
	if(!$rs)
	{
	echo "Error while exeuting the query";
	}
	else
	{
	while($row=mysql_fetch_array($rs))
		{
		$color_id=$row['ColorID'];
		$cName=$row['ColorName'];
		echo "<option value=\"$color_id\">$cName</option>";
		}
	}
}

records displayed: (and the actual color names displyed!!!)

echo "<SELECT name=\"size\" value=\"$size\">";
showSize($II);
echo "</SELECT> ";

record selected inserted into a temp table: (but the color value instead of the
color name goes in)

mysql("$DBName","INSERT INTO CartItems VALUES
('$UID','$ItemID','$ItemQuantity','$Date','$CartItemsID','$ColorName','$size')")
;

I have tried inserting color_id and cName too but no joy.  This is not making
sense.  I has previously been said but that just doesn't follow with the logic.

If a color name has been pulled why isn't the said color name selected being
inserted.  If this makes sense to someone I am listening with speakers turned up
high.

Thank you

Andrew






More information about the thelist mailing list