top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Update non-empty values only in mysql table?

+1 vote
369 views

My issue is that I have a PHP FORM that is submitting values through more than 55 input-text-fields, into a MySQL table.

Now, when I use UPDATE feature, suppose for e.g for 3 fields:

$sql="UPDATE pathology_test_rates SET bsugar_random='$bsugar_random', bsugar_fasting='$bsugar_fasting', bsugar_pp='$bsugar_pp'";

And then , if I want to update only 1 value, out of above 3, using PHP FORM, its making other 2 values empty. Whereas, I want other 2 values to remain un-disturbed.

How to do this ? Please help. M not using id in table.

posted Jul 1, 2014 by Vrije Mani Upadhyay

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

You can use where condition to update for example

$sql = "update datatwo set age = 30 where employeeid = 40;"
answer Jul 3, 2014 by Rajneesh
Similar Questions
+1 vote

I have a column called name in a table info
So I want to update that with it's current value, like this name + user_input. I tried with this code but not working

mysql_query("UPDATE info SET name = name + '$user_input' WHERE id='$user_id'");

But It returns 0 and update column to 0....

Any idea how to accomplish this task?

–1 vote

I want to update my sql database record and want to populate the value of previous record. So anybody can help me to get the previous value of the record to show when the update require.

0 votes

Sometime back I upgraded our server from 1.7.5 to 1.8.8. On an automated build machine we had no issues with timeouts in 1.7.5. However, after upgrading to 1.8.8, client CLI as well, I am running into this time out error about 60% of the time. I have at least one other user running into this as well.

Any ideas or suggestions as to how to correct or work around this issue?

...