My Carousel只显示数据库中的第一个内容,但不会显示下一个和之后的内容
这是我的代码和查询 它不会显示第二张图像 但它显示第一张图像 任何人都可以帮助谢谢
<?php
require_once("db2.php");
$GardenDBB = new GardenDBB();
$result = ($GardenDBB->LoadAllGallery());
$num_rows = mysql_num_rows($result);
$counter = 1;
while($db_field = mysql_fetch_array($result)){
?>
<div class="item<?php if ($counter <= 1){echo " active"; ?>" style="background-image: url(<?php echo './upload2/'.$db_field['image_name']?>")>;
<?php
echo '<div class="container">';
echo '<div class="row slide-margin">';
echo '<div class="col-sm-6">';
echo '<div class="carousel-content">';
echo '<h1 class="animation animated-item-1">'.$db_field['proName'].'</h1>';
echo '<h2 class="animation animated-item-2">'.$db_field['proDescription'].'</h2>';
echo '</div>';
echo '</div>';
echo '</div>';
echo '</div>';
echo '</div>';
$counter++;
}
}
?>
public function LoadAllGallery() {
$db_found = $this->connect_Db();
if ($db_found) {
$SQL = "SELECT * FROM tbl_car";
$result = mysql_query($SQL);
return $result;
mysql_free_result($result);
}
else {
$errorMsg = "Database NOT Found, Please connect your administrator ";
}
$this->close_DB();
}
答案 0 :(得分:0)
这应该有效
if ($counter <= 1)
{
// DIV CLASS="ITEM" wrapper starts here
}
//all the rest of the display code
if ($counter <= 1)
{
echo '</div>'; // DIV CLASS="ITEM" end of wrapper
}
$counter++;