Forum Moderators: coopster

Message Too Old, No Replies

update multiple fields depending on 1 field

         

wheelie34

3:17 pm on Sep 29, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have a routine to check an existing field, if its true then I make it update a specific field in the table, like this

$result=mysql_query("select field from table where field2='$bla'" );
if ( $result < $field )
{
$sql="update table set field ='$blabla' where field2='$bla'";

This works fine and updates field if its less than $field, I would like it to update 3 fields now so I tried.

update table set field='$blabla' set field3 ='$bladybla' set field4 ='$bladybladybla' where field2='$bla';

Now it does nothing at all, no errors no updates even though field is less than the new $field.

Am I right in just selecting field for the initial evaluation?

thanks in advance ;)

supermanjnk

3:35 pm on Sep 29, 2006 (gmt 0)

10+ Year Member



Hey wheelie34,

You should only use set once at the beginning, not for each field. Also, make sure that you have a comma in between each field you want to update.
$sql = "update table set field='test', field2='test2', field3='test3' WHERE field='whatever'";