繁体   English   中英

MySQL从1查询中选择第二行

[英]Mysql Select Second Row from 1 query

您如何做到这一点,我们才能到达查询的第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>
                        ';

第二行:

                            <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++;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM