을 가지고 있으며, 여기에 나는 "gallery_kategori"디스플레이 이미지 지금
오류가 나타나고 다음과 같이 설명 갈리아의 카테고리의 ID해야한다는 등의 준비 과정에서 오전 : 오류 2 : 밖으로 명령 sync; 이 명령을 지금 실행할 수 없습니다.
내가 원하는 것 : - 갤러리에 들어가서 카테고리 또는 영역보다 속하는 사진을 찍고 싶습니다. - 항상 함께 있어야하는 것은 아니며 각 이미지에 대해 한 번에 하나의 이미지 여야합니다. 당신이 그 연결을 첫 번째 결과를 해제하지 않았기 때문에 코드로 장난 일부 후
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;
}
}
$ kategori = $ id를 사용해보실 수 있습니까? $ stmt-> bind_param ('i', $ kategori);를 호출하기 전에; – Jason
@ Jason 작동하지 않을 수도 있습니다 : ( –