gpt4 book ai didi

php - Mysql 从 1 个查询中选择第二行

转载 作者:行者123 更新时间:2023-11-29 18:14:47 26 4
gpt4 key购买 nike

如何才能到达 fetch 中查询的第 2 行?

Query : select * from news where id_category_news = '1'

我用了一段时间来查询

while($event_res = mysqli_fetch_array($event_query))

我要

第 1 行将采取:

                        echo '<article class="post">
<a class="image_thumb_zoom" href="#" title="'.$event_res['title_news'].'">
<img width="371" height="177" src="dist/images/dummy/shutterstock_58382248-371x177.jpg" class="attachment-post-first wp-post-image" alt="shutterstock_58382248">
</a>
<h4 class="post-title">
<a href="#" title="'.$event_res['title_news'].'">'.$event_res['title_news'].'</a>
<span class="date">'.TimetoDate($event_res['time_news']).'</span>
</h4>
<p>'.$event_res['text_news'].'</p>
</article>
';

和第 2 行:

                            <article class="post">
<div class="entry clearfix">
<a href="#" title="Permalink to Nam nibh arcu tristique eget pretium vitae libero ac risus" rel="bookmark">
<img width="225" height="136" src="dist/images/dummy/photodune-3517559-idea-s-225x136.jpg" class="thumb wp-post-image" alt="photodune-3517559-idea-s">
<h4 class="post-title">Nam nibh arcu tristique eget pretiu...</h4>
</a>
<p>Nam nibh arcu, tristique eget pretium se...</p>
<div class="meta">
<span class="date">July 2, 2013</span>
</div>
</div>
</article>

最佳答案

为什么没有一个随着行的增加而增加的整数,如下所示:

$row = 1;

while($event_res = mysql_fetch_assoc($event_query)) {
//do something here...

if ($row == 1) {
// do row 1 things here...

} else if ($row == 2) {
// do row 2 things here...
}

$row++;
}

关于php - Mysql 从 1 个查询中选择第二行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47118316/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com