是否可以使用 php 和 mysql 只运行一个查询,然后执行两个具有不同结果的 while 循环。一世
//this is the query
$qry_offers = mysql_query("SELECT * FROM offers ORDER BY offer_end ASC");
在第一个循环中,我想显示“end_date”小于或等于今天的任何结果
<div id="current">
<?
while($row_offers = mysql_fetch_assoc($qry_offers)) {
if ( (date("Y-m-d H:i:s")) <= ($row_offers['offer_end']) ) {
echo '<li><a href="#">'.$row_offers['offer_name'].'</a></li>';
}
}
?>
</div><!-- END OF CURRENT -->
在第二个循环中,我想显示“end_date”大于今天的任何结果
//this is where i would have the 2n while loop
<div id="inactive">
<?
while($row_offers = mysql_fetch_assoc($qry_offers)) {
if ( (date("Y-m-d H:i:s")) > ($row_offers['offer_end']) ) {
echo '<li><a href="#">'.$row_offers['offer_name'].'</a></li>';
}
}
?>
</div><!-- END OF INACTIVE -->