Note that there are some explanatory texts on larger screens.

plurals
  1. POTrying to update column value for specific row only?
    primarykey
    data
    text
    <p>I am having some problems with a script, I am basically inputting data into a MySQL table. This data will be inserted in the table as 1 row. </p> <p>Upon a row of data being entered into the table I want the current/specific row currently being entered to have the column 'account_type' to be updated from its default value 'member' to 'client'.</p> <p>It's a long story why I need to do it this way but I do not want to simply just enter the value 'client' it must be updated from 'member' to client.</p> <p>The script I have (which is the bit at the bottom) is currently doing just this but it is affecting all rows in the table, is there a way I can add a where clause to the update to say only affect the current row being entered and do not update all other rows in the table?</p> <pre><code>&lt;?php ob_start(); // CONNECT TO THE DATABASE require('../../includes/_config/connection.php'); // LOAD FUNCTIONS require('../../includes/functions.php'); $username = $_POST['username']; $password = $_POST['password']; $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $email = $_POST['email']; $number = $_POST['number']; $dob = $_POST['dob']; $accounttype = $_POST['accounttype']; $query="INSERT INTO ptb_registrations ( username, password, firstname, lastname, email, number, dob, accounttype, date_created ) VALUES( '".$username."', '".$password."', '".$firstname."', '".$lastname."', '".$email."', '".$number."', '".$dob."', '".$accounttype."', now() )"; mysql_query($query) or die(); $query="INSERT INTO ptb_users ( first_name, last_name, email, password ) VALUES( '".$firstname."', '".$lastname."', '".$email."', MD5('".$password."') )"; mysql_query($query) or dieerr(); $result = mysql_query("UPDATE ptb_users SET ptb_users.user_id = ptb_users.id, ptb_users.account_type = 'Client'"); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload