Php 显示内容,但不显示最新内容
我有这些代码在我的网站上显示内容 Index.phpPhp 显示内容,但不显示最新内容,php,mysql,pdo,Php,Mysql,Pdo,我有这些代码在我的网站上显示内容 Index.php $rest = new rest; $list = $rest->fetch_all(); <?php foreach ($rest->fetch_all() as $rest) { ?> <br> <a href="episode.php?id=<?php echo $rest['cast_id']; ?>"> #<?php echo $rest['cast_id']; ?
$rest = new rest;
$list = $rest->fetch_all();
<?php foreach ($rest->fetch_all() as $rest) { ?>
<br>
<a href="episode.php?id=<?php echo $rest['cast_id']; ?>">
#<?php echo $rest['cast_id']; ?>: <?php echo $rest['cast_title']; ?>
<br>
<font size="2" color="red">
<?php echo $rest['cast_about']; ?></font></a><br>
<br><div class="divider"> </div><br>
<?php } ?>
请有人告诉我,我如何才能得到这个显示结果,但不是最新的结果
在mysql中,所有字段都使用ID标记进行编号
在我的网站上,我有这个列表上面列出的最新条目,所以我不需要最新的条目出现在这里
请帮忙
谢谢。最简单的方法是放弃应用程序中的行。您可以在SQL中使用计算出的限制来实现这一点。将其计算为podcast-1中的selectcount* 或: 不包括最后一行。您可以使用或根据您的查询排序,如下所示: 假设最新结果是查询结果的第一个原始结果
$rest = new rest;
$list = $rest->fetch_all();
$latest = array_shift($list);
<?php foreach ($list as $rest) { ?>
<br>
<a href="episode.php?id=<?php echo $rest['cast_id']; ?>">
#<?php echo $rest['cast_id']; ?>: <?php echo $rest['cast_title']; ?>
<br>
<font size="2" color="red">
<?php echo $rest['cast_about']; ?></font></a><br>
<br><div class="divider"> </div><br>
<?php } ?>
如果它是最后一个需要隐藏的原始数据,则使用array_popLIMIT 18446744073709551615查询结束时的偏移量10将忽略顶部的10行。试试看。基于没有。只是不显示结果。试试这个:从播客订单中选择*按播\u id DESC LIMIT 1000000偏移量1。谢谢@hal9000这对我有用。是的,这是个更好的主意+1添加$latest=array\u pop$列表;未显示任何更改。我已更新代码。您应该改用array_shift,请参见上面编辑的代码
SELECT *
FROM podcast
EXCEPT
SELECT TOP 1 *
FROM podcast
ORDER BY cast_id ASC
$rest = new rest;
$list = $rest->fetch_all();
$latest = array_shift($list);
<?php foreach ($list as $rest) { ?>
<br>
<a href="episode.php?id=<?php echo $rest['cast_id']; ?>">
#<?php echo $rest['cast_id']; ?>: <?php echo $rest['cast_title']; ?>
<br>
<font size="2" color="red">
<?php echo $rest['cast_about']; ?></font></a><br>
<br><div class="divider"> </div><br>
<?php } ?>