通过Id更新sql中的值

时间:2018-06-17 12:25:03

标签: php mysql

我有一个页面,其中我需要更新$ result中的记录。当用户名已存在于数据库中时,这将更新。但是我无法在$ result中获得记录的ID。

下面的

是我尝试过的代码:

$result = mysqli_query($con, "SELECT * FROM logcalls WHERE firstname='".$firstname."' LIMIT 1");

if(mysqli_num_rows($result)==1){

    $upd = "UPDATE logcalls SET totalcall = totalcall + 1 AND problem = '$_POST[problem]' AND dateinput = '$_POST[dateinput]' where id = '$_POST[id]'";
    mysqli_query($con, $upd);
    header('location: registration.php');
}

1 个答案:

答案 0 :(得分:0)

您应该使用public partial class Id

$result_data = mysqli_fetch_array($result);

或者$result = mysqli_query($con, "SELECT * FROM logcalls WHERE firstname='".$firstname."' LIMIT 1"); if(mysqli_num_rows($result)==1){ $result_data = mysqli_fetch_array($result); $upd = "UPDATE logcalls SET totalcall = totalcall + 1 AND problem = '".$_POST['problem']."' AND dateinput = '".$_POST['dateinput']."' WHERE id = '".$result_data['id']."'"; mysqli_query($con, $upd); header('location: registration.php'); }

中的WHERE firstname='".$firstname."'