if (isset($_GET['srId'])) {
$srId = $_GET['srId'];
}
$getShowroomDetails = $db->prepare('SELECT
a.id, a.roomName, a.roomImage, a.roomDetails,
b.id, b.showroom, b.activityName, b.activityPlace, b.activityDate,b.activityDetails,b.activityImage
FROM movies_showroom AS a
INNER JOIN movies_showroom_details AS b ON (a.id = b.showroom)
WHERE a.id=?
');
$getShowroomDetails->bind_param('i', $srId);
if ($getShowroomDetails->execute()) {
mysqli_stmt_bind_result($getShowroomDetails, $id, $roomName, $roomImage, $roomDetails, $showroom, $sid, $activityName, $activityPlace, $activityDate, $activityDetails, $activityImage);
$getShowroomDetails->fetch();
}
?>
现在在HTML
<div class="row">
<div class="col-sm-4 col-xs-12 pull-right">
<img src="../images/showRooms/<?php print $roomImage ?>" width="256"
height="256" alt="" class="img-responsive img-thumbnail"/>
</div>
<div class="col-sm-8 col-xs-12 pull-right">
<div class="pull-right">
<h4 class="text-bold">نبذه عن القاعة</h4>
<?php print $roomDetails ?>
</div>
</div>
</div>
现在是while循环
while (mysqli_stmt_fetch($getShowroomDetails)) {
printf("%s %s\n", $activityName, $activityPlace);
}
这里while loop
只读第一行吗?
答案 0 :(得分:0)
如果我遇到问题,你正在寻找mysqli_fetch_all()
有关详细信息,请参阅http://php.net/manual/en/mysqli-result.fetch-all.php。
留意你的记忆。如果你假设一个巨大的结果,更好的(更低的内存影响)方式是在模板的循环中处理它。在您的情况下,这可能会有所不同,具体取决于您的设置:)
<div>
<h4 class="text-bold">نبذه عن القاعة</h4>
<?php
while (mysqli_stmt_fetch($getShowroomDetails)) {
printf("%s %s\n", $activityName, $activityPlace);
}
print $roomDetails ?>
</div>
答案 1 :(得分:0)
由于您需要打印所有记录,您可以使用mysqli_fetch_array:
mysqli_fetch_array($result,MYSQLI_ASSOC); // Associative array
在您的代码中执行以下更改:
while ($row = mysqli_fetch_array($getShowroomDetails,MYSQLI_ASSOC)) {
print_r($row); // it gives all the records
// printf("%s %s\n", $activityName, $activityPlace); // I don't know why you have used it, that's why I've commented this line
}