如何通过更新增加价值?

时间:2015-05-23 14:48:05

标签: php mysql

如何通过更新增加价值?此代码将注册ID中的值复制到url。例如,如果id=1url=1。如何订购更新id=1然后url=id1id=2然后url=id2。提前谢谢!

我需要这种

  

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 );
}

1 个答案:

答案 0 :(得分:1)

试试这个:

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

或者我没有得到问题?