Jump to content

Recommended Posts

So, I've read up on a couple things on updating multiple fields, but I wanted to run this by you...

 

Can you do this so it's under one query?

 

$query = (UPDATE...) AND (UPDATE...) AND, etc? 

 

What would be the cleanest way to do this?  I have 36 fields being updated.  Thanks!

Link to comment
https://forums.phpfreaks.com/topic/146912-update-multiple-fields/
Share on other sites

I see how that'd work, but in my case every field will be different...

 

For example...

("UPDATE `$tbl_name` SET `amount` = '$budg_mustang' WHERE `sub_category` = 'Mustang'");

("UPDATE `$tbl_name` SET `amount` = '$budg_vulcan' WHERE `sub_category` = 'Vulcan'");

 

All 36 of them...

Any thoughts anyone?

 

If I have to do individual queries for each... would I just do something similar?:

 

$query_mustang = ("UPDATE `$tbl_name` SET `amount` = '$budg_mustang' WHERE `sub_category` = 'Mustang'");

$query_vulcan = ("UPDATE `$tbl_name` SET `amount` = '$budg_vulcan' WHERE `sub_category` = 'Vulcan'");

if (mysql_query($query_mustang, $query_vulcan)) {
    echo "Your budget has been updated!  <br> Would you like to make another modification?  <a href='budg_retrieve.php'>Yes</a>";
}else {
    die(mysql_error());
}

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.