在我的 while 循环中中断。一直在阅读php手册,但无法弄清楚我在这里做错了什么......
$pdo 调用我的数据库连接
function getSelectedPhoto($the_selected_id) {
global $pdo;
$id = $the_selected_id;
$stmt = $pdo->prepare("SELECT handle, src FROM images WHERE id = :id LIMIT 1");
$vars = array(':id' => $id);
$result = $stmt->execute($vars);
if($result) {
while($row = $result->fetchObject()) {
echo '<img src="../' . $row->src . '" alt="image" /><br />';
echo '<p id="handle">' . $row->handle . '</p>';
}
} else die("There was some problem");
}