我正在嘗試使用 while 循環(huán)使用唯一標識符填充 mysql 數(shù)據(jù)庫中的列,但 uniqid 一遍又一遍地重復相同的輸出。這是我的代碼:$dblink = mysqli_connect($host,$dbu,$dbp);$dblink->set_charset("utf8");$seldb = mysqli_select_db($dblink, $db); $dblink = new mysqli($host, $dbu, $dbp, $db); $result = $dblink->query(" SELECT * FROM `mytable` "); while ($row = $result->fetch_assoc()) { $uniquecode = uniqid(); $sql = mysqli_query($dblink,"UPDATE `mytable` SET `code`='$uniquecode' "); }我究竟做錯了什么?
PHP uniqid 在 while 循環(huán)的每次迭代中重復
ibeautiful
2023-10-21 10:13:22