Javascript 画廊图片没有显示他们的订单
我有一个gallery.php文件。它由相册和画廊图片组成。我的问题是,当我点击相册图像时,画廊图像开始从图像4/4显示,然后是图像3/4,依此类推 gallery.phpJavascript 画廊图片没有显示他们的订单,javascript,php,css,Javascript,Php,Css,我有一个gallery.php文件。它由相册和画廊图片组成。我的问题是,当我点击相册图像时,画廊图像开始从图像4/4显示,然后是图像3/4,依此类推 gallery.php <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/lightbox-plus-jquery.min.js"></script> &
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/lightbox-plus-jquery.min.js"></script>
<div class="menu-port">
<div class="container">
<div class="menu-grid-main">
<?php
include("database/connection.php");
$result=mysql_query("SELECT * from Album_image where status='process'");
while ($row1= mysql_fetch_array($result)) {
?>
<div class="col-md-4 menu-grid wow bounceInDown" data-wow-delay="0.3s">
<?php
include("database/connection.php");
$result1=mysql_query("SELECT * from Gallery_image where aid=$row1[aid]");
while ($row2= mysql_fetch_array($result1)) {
?>
<a href="admin/gcatch//<?php echo $row2['image'] ?>" data-lightbox="<?php echo $row1['name']?>" >
<?php }?>
<img src="admin/acatch/<?php echo $row1['image'] ?>" alt="" class="img-responsive">
</a>
<h3><?php echo $row1['name']?></h3>
<p><?php echo $row1['des']?></p>
</div>
<?php }?>
<div class="clearfix"> </div>
</div>
</div>
</div>
这里有语法问题。试试这个
<div class="menu-port">
<div class="container">
<div class="menu-grid-main">
<?php
include("database/connection.php");
$result=mysql_query("SELECT * from Album_image where status='process'");
while ($row1= mysql_fetch_array($result)) {
?>
<?php
include("database/connection.php");
$result1=mysql_query("SELECT * from Gallery_image where aid=$row1[aid]");
while ($row2= mysql_fetch_array($result1)) {
?>
<div class="col-md-4 menu-grid wow bounceInDown" data-wow-delay="0.3s">
<a href="admin/gcatch//<?php echo $row2['image'] ?>" data-lightbox="<?php echo $row1['name']?>" >
<img src="admin/acatch/<?php echo $row1['image'] ?>" alt="" class="img-responsive">
</a>
<h3><?php echo $row1['name']?></h3>
<p><?php echo $row1['des']?></p>
</div>
<?php }?>
<?php }?>
<div class="clearfix"> </div>
</div>
</div>
</div>
此查询更适合于获取数据
"SELECT * from Gallery_image where aid=$row1[aid] ORDER BY id DESC"
排序结果是确定取数顺序的最佳方法
记住:mysql_*函数(mysql_connect或mysql_query)不推荐使用!您应该使用PDO或至少mysqli函数
以下是一些学习PDO的资源:
/如果在select查询中没有一个order by
,您永远不知道数据的顺序。这也没有变化。它正在工作,但相同的相册图像在第2行中重复出现。我怎样才能解决这个问题@马赫什:是的,因为你的循环。你能从一个查询而不是两个查询中得到结果吗。您应该加入表并获得1个查询结果。然后可以循环一个查询结果。