General discussion
how to update multiple sql columns

Hey guys!

I have read somewhere that the way to update multiple sql columns would be to add a coma? I can't get this code to work and it should update two subscriptionplans for the user instead of just one..

if ($subscriptionplan == 'Level 1' && $row['subscriptionplan'] == 'None' && $subscriptionplan2 == 'Level 2' && $row['subscriptionplan2'] == 'None' && $subscriptionplan3 == 'None' && $row['subscriptionplan3'] == 'None'smile {

        $sql = "UPDATE memberships
                SET subscriptionplan = '$subscriptionplan', subscriptionplandate = now(), fees3 = $fees3, paid = $paid, expirydate = now() + interval '1' day, paidbydate = now() + interval '1' day, overdue = $overdue, totalfees = $totalfees, subscriptionplan2 = '$subscriptionplan2'
                WHERE user_uid = '".$_SESSION['u_uid']."'

               ";
        mysqli_query($conn, $sql);
        header("Location: update.php?subscription=success");
        exit();







         } else {


         }
Hey guys! I have read somewhere that the way to update multiple sql columns would be to add a coma? I can't get this code to work and it should update two subscriptionplans for the user instead of just one.. if ($subscriptionplan == 'Level 1' && $row['subscriptionplan'] == 'None' && $subscriptionplan2 == 'Level 2' && $row['subscriptionplan2'] == 'None' && $subscriptionplan3 == 'None' && $row['subscriptionplan3'] == 'None') { $sql = "UPDATE memberships SET subscriptionplan = '$subscriptionplan', subscriptionplandate = now(), fees3 = $fees3, paid = $paid, expirydate = now() + interval '1' day, paidbydate = now() + interval '1' day, overdue = $overdue, totalfees = $totalfees, subscriptionplan2 = '$subscriptionplan2' WHERE user_uid = '".$_SESSION['u_uid']."' "; mysqli_query($conn, $sql); header("Location: update.php?subscription=success"); exit(); } else { }

Yes we can update multiple columns using comma seperation.Normal update query as follows:

$sql = “"UPDATE tablename SET column_1 = value, column_2 = value WHERE condition = condition_value”

If your database doesn’t update then first of all print $sql and you will get your sql query which will execute and run this query in your phpmyadmin. If there will be any issue you can easily find.
Also check your condition it may be your condition is not working.
You can use multiple condition in where clause to update multiple row or can also use update query multiple time.

Yes we can update multiple columns using comma seperation.Normal update query as follows: $sql = “"UPDATE tablename SET column_1 = value, column_2 = value WHERE condition = condition_value” If your database doesn’t update then first of all print $sql and you will get your sql query which will execute and run this query in your phpmyadmin. If there will be any issue you can easily find. Also check your condition it may be your condition is not working. You can use multiple condition in where clause to update multiple row or can also use update query multiple time.

Webguru Infosystems PHP Programming Company - https://www.webguru-india.com/php-programming-services

86
1
4
live preview
enter atleast 10 characters
WARNING: You mentioned %MENTIONS%, but they cannot see this message and will not be notified
Saving...
Saved
With selected deselect posts show selected posts
All posts under this topic will be deleted ?
Pending draft ... Click to resume editing
Discard draft