php - mysql query selecting wrong field -


$something_else = mysql_query('select image_id items p left join list on p.item_id = up.item_id up.userid =  "' . $user_id . '"');       while ($r=mysql_fetch_assoc($something_else)){          foreach($r $item_id2)  $query ='delete list userid="' .$user_id. '" , item_id="' .$item_id2. '"';} 

this product "wish list." each relative user. can add wish list, can't delete proper item. code doing deleting last item on list, or perhaps item highest 'image_id'.

either way, i'm not getting relative 'image id' pertaining the associated item.

i'm pretty sure should enough information solve problem. i'm problem lies in mysql query:

mysql_query('select image_id items p left join list on p.item_id = up.item_id up.userid = "' . $user_id . '"');

first of mentioned before queries not secure, please use pdo. anyways try :

$something_else = mysql_query('select image_id items p left join list on p.item_id = up.item_id up.userid =  "' . $user_id . '"');  while ($r=mysql_fetch_assoc($something_else)) {         $query ='delete list userid="' .$user_id. '" , item_id="' .$r['image_id'] . '"'; } 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -