Jump to content

Trying to update a DB field where another field and an array item match


tyler_durden

Recommended Posts

$new_array2=array_diff($my_array,$itemIds);

$updatedb = mysql_query("UPDATE content_type_ads SET field_expire_value = '666' WHERE $new_array2 = field_item_id_value");

 

"$new_array2" has only 12 digit numbers for each item in the array, and I want to match them to the "field_item_id_value" field in the table, updating the "field_expire_value" field for the record where they match.  I know I am close because the UPDATE code works before I add the WHERE statement (it of course adds '666' to EVERY field, but for a noobie it's a start!).

 

Link to comment
Share on other sites

Thanks for the suggestions. I researched the IN function a bit and implemented the below code.  I am now getting an error "Parse error: syntax error, unexpected ';' in " on that line, and if I remove the ";" then the error moves to the next line where I have "?>", both unexpected ends.  Do I have to create the comma seperated list BEFORE this step?

 

$updatedb = mysql_query("UPDATE content_type_ads SET field_expire_value = '666' WHERE field_item_id_value IN (".implode(',', $new_array2).")";

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.