且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

php mysql更新表一次

更新时间:2022-12-26 12:35:43

我认为您应该再添加一个field,例如:number_update到您的pin表中.默认值为0 首次更新时,其值为1,您可以检查该值, 如果它是1,将警告ID Already in Use, Pls login.如果是0,请允许更新

I think you should add one more field like: number_update into your pin table first. Default value is 0 First time update, it will have value is 1 and you could check that value, if it is 1, will alert ID Already in Use, Pls login. If it is 0, allow to update

$result = mysql_query("SELECT * FROM pin WHERE Pin  = '$Pin'");
$test = array();
while ($row = mysql_fetch_array($result)) {
    $test[] = array_map('utf8_encode', $row);
}

if($test["number_update"] == 1) { //Checking already updated
    //Notify user that they have already updated
} else {
    mysql_query("UPDATE pin SET appid ='$num' WHERE Pin= '$Pin'")
        or die(mysql_error());
}