gpt4 book ai didi

php - MYSQL循环分别更新行值

转载 作者:行者123 更新时间:2023-11-29 04:38:36 25 4
gpt4 key购买 nike

<分区>

我有以下 php:

<?php
$connection=mysqli_connect("host","user","pass","db");
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($connection,"SELECT ID FROM tbname");
while($row = mysqli_fetch_array($result))
{
mysqli_query($connection,"UPDATE tbname SET amount= (amount+ 1) WHERE ID='$row[ID]' ");
}
mysqli_close($connection);
echo 'OK'; ?>

我想“关联”按钮的按下以更新表中的关联行值,但是当我使用此代码时,我更新了所有值。谁能帮帮我?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com