我需要更新数据库中的40行,从userID
匹配的位置开始。我不想确定行号,因为最终这个数据库将是巨大的。SQL多个更新语句
我想要做的就是简单地说:
“我的阵列更新这些未来的40行,其中用户ID = myUserID”
以下是我有:
<?php
// connect to the database and select the correct database
$con2 = mysql_connect("localhost","Database","Password");
if (!$con2)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("ifaves_code", $con2);
$i = 0;
while ($i < 40) {
//cycle through the array
$cycleThrough2 = $updatedUserNames[$i];
//$query = "UPDATE tblUserLinks SET `URLName` = '$cycleThrough2' WHERE userID = '" . $mainUID . "' LIMIT 1";
mysql_query($query) or die ("Error in query: $query");
++$i;
}
mysql_close();
?>
变量$mainUID
被正确设置,我遇到的问题是它似乎没有更新发生在数据库中。
如何改变我现有的代码来接收我想要的行为?
当你说“下一个40行”你是什么意思?接下来以什么顺序? –