繁体   English   中英

如何修复更新数据库中的所有行?

[英]How can i fix updating all my rows in Database?

所以我读过我的表行是这样的: Read of rows in database

当我尝试更新它时,它会更新我的所有行:这是当我单击更新时,它会在行中显示数据

当我更改一个数据时,例如我将名称更改为“IVICA”,所有名称都会更改。 在此处输入图像描述

<?php
include_once 'database.php';
if(count($_POST)>0) {
mysqli_query($conn,"UPDATE rezervacije set check_in='" . $_POST['check_in'] . "', check_out='" . $_POST['check_out'] 
. "', ime_turista='" . $_POST['ime_turista'] . "' ,prezime_turista='" . $_POST['prezime_turista'] 
. "' ,email_turista='" . $_POST['email_turista'] 
. "' ,broj_osobne='" . $_POST['broj_osobne'] 
. "' ,drzavljanstvo='" . $_POST['drzavljanstvo'] 
. "' ,god_rod_turista='" . $_POST['god_rod_turista']
. "' ,id_apartmana='" . $_POST['id_apartmana'] 
. "'");
$message = "Record Modified Successfully";
}
$result = mysqli_query($conn,"SELECT * FROM rezervacije WHERE id_rezervacije='" . $_GET['id_rezervacije'] . "'");
$row= mysqli_fetch_array($result);
?>
<html>
<head>
<title>Ažuriraj rezervaciju</title>
</head>
<body>
<form name="azuriraj" method="post" action="">
<div><?php if(isset($message)) { echo $message; } ?>
</div>
<div style="padding-bottom:5px;">
<a href="prikaz_rezervacija.php">Prikaz rezervacija</a>
</div>
Check In: <br>
<input type="date" name="check_in" value="<?php echo $row['check_in']; ?>">
<br>
Check Out: <br>
<input type="date" name="check_out" value="<?php echo $row['check_out']; ?>">
<br>
Ime turista :<br>
<input type="text" name="ime_turista" value="<?php echo $row['ime_turista']; ?>">
<br>
Prezime turista:<br>
<input type="text" name="prezime_turista" value="<?php echo $row['prezime_turista']; ?>">
<br>
Email turista:<br>
<input type="text" name="email_turista" value="<?php echo $row['email_turista']; ?>">
<br>
Broj osobne:<br>
<input type="text" name="broj_osobne" value="<?php echo $row['broj_osobne']; ?>">
<br>
Drzavljanstvo:<br>
<input type="text" name="drzavljanstvo" value="<?php echo $row['drzavljanstvo']; ?>">
<br>
Godina rođenja turista<br>
<input type="date" name="god_rod_turista" value="<?php echo $row['god_rod_turista']; ?>">
<br>
ID Apartmana<br>
<input type="text" name="id_apartmana" value="<?php echo $row['id_apartmana']; ?>">
<br>
<input type="submit" name="submit" value="Submit" class="buttom">

</form>
</body>
</html>

您需要通过添加where条件来定义哪一行。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM