[thelist] php query problem

Dunstan Orchard dunstan at 1976design.com
Tue Oct 15 16:57:01 CDT 2002

can anyone tell me why this code reults in _two_ copies of each image being
inserted into table 'cart'?

// adds all images from a user's lightbox to their cart
function lightbox_add_cart_all($userid)
$query = ("SELECT * FROM lightbox WHERE (userid = '$userid')");
$result = mysql_query($query);

while ($row = mysql_fetch_array($result))
 $imageid = $row['imageid'];
 $query2 = ("INSERT INTO cart (userid, imageid) VALUES
('$userid', '$imageid')");
 $result2 = mysql_query($query2);

thanks very much - dunstan

Dorset, England

More information about the thelist mailing list