Узбек Баха
Узбек Баха

Reputation: 195

How to add value through the update?

How to add value through the update? This code copies the value in the registration id to the url. For example, if id=1 then url=1. How to order update id=1 then url=id1, id=2 then url=id2. Thanks in advance!

I need this kind of

url = 'id+".$last_id."'

function register_user($register_data) {
    global $con;

   $con = mysqli_connect('Localhost','social','social','social');

    array_walk($register_data, 'array_sanitize');
    $register_data['password'] = md5($register_data['password']);

    $fields = '`' . implode('`, `', array_keys($register_data)) . '`';
    $data = '\'' . implode('\', \'', $register_data) . '\'';

    $insert = "INSERT INTO users($fields) VALUES ($data) ";
    mysqli_query($con,$insert);
    $last_id = mysqli_insert_id($con);
    $update = "UPDATE users SET url = '".$last_id."' WHERE id = ".$last_id." ";
    mysqli_query($con,$update );
}

Upvotes: 0

Views: 47

Answers (1)

Richard
Richard

Reputation: 2815

Try this:

$update = "UPDATE users SET url = 'id".$last_id."' WHERE id = ".$last_id." ";

Or did not I get the question?

Upvotes: 1

Related Questions