这里我已经包含了我的代码
<?php
$var1=$_POST["select1"];
$var2=$_POST["select2"];
mysql_connect("localhost","root","") or die("Connection Error");
mysql_select_db("cityoffers") or die("Database Error");
if(isset($var1) and empty($var2))
{
$res=mysql_query("select * from product where Category='$var1'");
while($row = mysql_fetch_array($res))
{
?>
<ul class="cd-items cd-container">
<li class="cd-item">
<img src="img/item-1.jpg" alt="Item Preview">
<a href="#0" class="cd-trigger"><?php
echo "Company Name: ".$row[2];?></a>
</li>
</ul>
<div class="cd-quick-view">
<div class="cd-slider-wrapper">
<ul class="cd-slider">
<li class="selected"><img src="img/item-1.jpg" alt="Product 1"></li>
<li><img src="img/item-2.jpg" alt="Product 2"></li>
<li><img src="img/item-3.jpg" alt="Product 3"></li>
</ul>
<ul class="cd-slider-navigation">
<li><a class="cd-next" href="#0">Prev</a></li>
<li><a class="cd-prev" href="#0">Next</a></li>
</ul>
</div>
<div class="cd-item-info">
<h2><?php echo "Company Name: ".$i++ .$row[2];?></h2>
<p><?php echo "Product Name: ".$row[3]."<br>";
echo "Offer Percentage: ".$row[4]."<br>";
echo "Start Date: ".$row[5]."<br>";
echo "End Date: ".$row[6]."<br>"; ?></p>
<ul class="cd-item-action">
<li><button class="add-to-cart">Add to cart</button></li>
<li><a href="#0">Learn more</a></li>
</ul>
</div>
<a href="#0" class="cd-close">Close</a>
</div>
<script src="js/jquery-2.1.1.js"></script>
<script src="js/velocity.min.js"></script>
<script src="js/main.js"></script>
<?php
}
}
?>
我已经在jQuery之间包含了PHP代码。我认为while循环不起作用。 PHP代码单独获取最后一行并显示它。请给我一个解决方案。