dqyp50298 2017-03-29 22:29
浏览 34
已采纳

如何横向逐一显示新闻?

code:

<?php
   $query = "select * from latest_news limit 0,10";
   $fet = mysqli_query($link,$query);
   while ($fetch = mysqli_fetch_array($fet)) 
    {
      $news_title = $fetch['news_title'];
    }
?>

html code:

<marquee onmouseover="this.stop();" onmouseout="this.start();">
    <h3 id="news-h3"><?php echo $news_title; ?></h3>
</marquee>

I am diplaying news_title using marquee but here only one data are showing. I want to display all news_title one by one. So, how can I do this.

Thank You

  • 写回答

2条回答 默认 最新

  • dsfs23434 2017-03-29 22:38
    关注

    Here is what you want.

    <marquee onmouseover="this.stop();" onmouseout="this.start();">
        <?php
            $query = "select * from latest_news limit 0,10";
            $fet = mysqli_query($link,$query);
            while ($fetch = mysqli_fetch_array($fet)) 
            {
              $news_title = $fetch['news_title'];
              ?>
                <span id="news-h3"><?php echo htmlspecialchars($news_title); ?></span>
              <?php
            }
        ?>
    </marquee>
    

    Use CSS to style news span. If you want to use h3 tag then style it also like:

    <style>
    h3 {
       display: inline;
    }
    </style>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)
编辑
预览

报告相同问题?