我有一个页面,其中我需要更新$ 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');
}
答案 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."'