0
私の更新ステートメントが機能していません。 "RECORD UPDATED"と表示されますが、テーブルは更新されません。ここにコードがありますので、助けてください。WHILEループおよび配列を使用したPHP更新ステートメント
<?php
$db=mysqli_connect("localhost","root","")or die("Connection error");
mysqli_select_db($db,"suhaib")or die("dbase error");
連想配列を作成し、テーブルを更新するために、WHILEループ
<?php
if(isset($_GET['edit'])){
$sql=$db->query("SELECT * FROM forma");
while($result=mysqli_fetch_assoc($sql)){
?>
<form name="update1" action="" method="GET">
DataNumber:<input type="text" name="datanum"
value="<?php echo $result['datanumber']; ?>">
Date:<input type="text" name="date" value="<?php echo $result['date']; ?>">
Type:<input type="text" name="type" value="<?php echo $result['type']; ?>">
Subject:<input type="text" name="subject"
value="<?php echo $result['subject']; ?>">
Amount:<input type="text" name="amount"
value="<?php echo $result['amount']; ?>">
SOE:<input type="text" name="soe" value="<?php echo $result['soe']; ?>">
Note:<input type="text" name="note" value="<?php echo $result['note']; ?>">
Liquidate:<input type="text" name="liquidate"
value="<?php echo $result['liuidatedate']; ?>">
Checker Info:<input type="text" name="checkerinfo"
value="<?php echo $result['checkerinfo']; ?>">
Accounting Info:<input type="text" name="accountingconfir"
value="<?php echo $result['accountingconfir']; ?>">
<input type="submit" value="update" name="upd">
</form>
<?php }} ?>
UPDATE文を実行しています。表は更新されていないが、それは「レコードが更新」メッセージが表示さ
if(isset($_GET['upd'])){
$datanum=$_GET['datanum'];
$date=$_GET['date'];
$type=$_GET['type'];
$subject=$_GET['subject'];
$amount=$_GET['amount'];
$soe=$_GET['soe'];
$note=$_GET['note'];
$liquidate=$_GET['liquidate'];
$checkerinfo=$_GET['checkerinfo'];
$accounting=$_GET['accountingconfir'];
$up="UPDATE forma SET datanumber='$datanum' , date='$date' ,
type='$type' , subject='$subject' ,
amount='$amount', soe='$soe' , note='$note', liuidatedate='$liquidate' ,
checkerinfo='$checkerinfo', accountingconfir='$accounting'";
mysqli_query($db, $up);
echo "record updated";
テーブル全体のデータや特定のIDを更新する – Bhargav
HTMLに正しく色付けされるように、 '<?php'タグを追加しました。 – ArtisticPhoenix
mysqli_query($ db、$ up)またはdie(mysqli_error($ db)); ' – Barmar