我正在尝试为下面的MySQL查询调整以下代码,但无法解决如何执行此操作。该查询应该只返回一行,并且我想从该行的“代码”列中提取数据,并将其作为变量传递给我的PHP脚本。将MySQL查询返回的单列值传递给PHP脚本
/* prepare statement */
if ($stmt = $mysqli->prepare("SELECT Code from Clients where Name='Jane'")) {
$stmt->execute();
/* bind variables to prepared statement */
$stmt->bind_result($code);
/* fetch values */
while ($stmt->fetch()) {
printf($code);
}
/* close statement */
$stmt->close();
}
谢谢,效果很好。 – Nick 2013-02-18 16:36:37