【发布时间】:2012-04-04 18:24:08
【问题描述】:
是否有可能在 while lopping 的准备好的语句中做一些像我们在普通 mysqli 查询中所做的事情。 例如
$sql = "SELECT * FROM users"*;
$query = mysqli_query($link, $sql);
while($row = mysqli_fetch_assoc($query)){
echo $row['username'];
echo $row['name'];
}
在准备好的语句中,它是这样的
$fetch_comments = $friend_zone->prepare("SELECT item_poster, comment FROM status_comments WHERE status_id = ? and item_poster = ?");
$fetch_comments->bind_param("is", $status__id, $item_poster);
$fetch_comments->execute();
$fetch_comments->store_result();
$fetch_comments->bind_result($item_poster_fetched, $comment_fetched);
while($fetch_comments->fetch(){
echo $item_poster;
}
我的意思是我想做这样的回声
echo $row['something'];
我现在想出的解决方案是使用绑定结果获取它们,然后将它们放入循环内的数组中,然后将它们放入 foo['bar']; 或类似的东西中。
有没有更好的办法?
【问题讨论】:
标签: php arrays while-loop mysqli prepared-statement