php mysqli准备的语句喜欢

php mysqli准备的语句喜欢,第1张

php mysqli准备的语句喜欢

这是您正确获取结果的方式

$param = "%{$_POST['user']}%";$stmt = $db->prepare("SELECt id,Username FROM users WHERe Username LIKE ?");$stmt->bind_param("s", $param);$stmt->execute();$stmt->bind_result($id,$username);while ($stmt->fetch()) {  echo "Id: {$id}, Username: {$username}";}

或者您也可以:

$param = "%{$_POST['user']}%";$stmt = $db->prepare("SELECt id,Username FROM users WHERe Username LIKE ?");$stmt->bind_param("s", $param);$stmt->execute();$result = $stmt->get_result();while ($row = $result->fetch_array(MYSQLI_NUM)) {  foreach ($row as $r) {    print "$r ";  }  print "n";}


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5505843.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-12
下一篇 2022-12-12

发表评论

登录后才能评论

评论列表(0条)

保存