现在和这里我正在准备“gallery_kategori”应该是高卢类别的ID
出现错误并描述如下:错误 2:命令不同步;你现在不能运行这个命令
我想要的: - 希望它进入画廊并拍摄属于类别或区域的照片。- 它不应该一直在一起,并且对于每个图像一次应该只有一个图像。
function galleryKategori()
{
if ($st = $this->mysqli->prepare('SELECT id, title FROM gallery_kategori')) {
$st->execute();
$st->bind_result($id, $title);
while ($st->fetch()) {
?>
<a href="/galleri-indhold/<?php echo $id;?>/">
<div class="galleryKategori">
<h4><?php echo $title;?></h4>
<?php
if ($stmt = $this->mysqli->prepare('SELECT rank, img FROM gallery WHERE kategori = ?')) {
$stmt->bind_param('i', $kategori);
$kategori = $id;
$stmt->execute();
$stmt->bind_result($rank, $img);
while ($stmt->fetch()) {
if($rank == 2)
{
}
}
$stmt->close();
} else {
echo 'Error 2: ' . $this->mysqli->error;
}
?>
</div>
</a>
<?php
}
$st->close();
}
else {
echo 'Error 1: ' . $this->mysqli->error;
}
}
EIDT 版本
function galleryKategori()
{
$st->free_result();
if ($st = $this->mysqli->prepare('SELECT id, title FROM gallery_kategori')) {
$st->execute();
$st->bind_result($id, $title);
while ($result->fetch()) {
?>
<a href="/galleri-indhold/<?php echo $id;?>/">
<div class="galleryKategori">
<h4><?php echo $title;?></h4>
<?php
if ($stmt = $this->mysqli->prepare('SELECT rank, img FROM gallery WHERE kategori = ?')) {
$kategori = $id;
$stmt->bind_param('i', $kategori);
$stmt->execute();
$stmt->bind_result($rank, $img);
while ($stmt->fetch()) {
if($rank == 2)
{
echo "Hey";
}
}
$stmt->close();
} else {
echo 'Error 2: ' . $this->mysqli->error;
}
?>
</div>
</a>
<?php
}
$st->close();
}
else {
echo 'Error 1: ' . $this->mysqli->error;
}
}