Php 如何水平显示一条又一条新闻?

Php 如何水平显示一条又一条新闻?,php,mysqli,Php,Mysqli,代码: html代码: <?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代码:

<?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'];
    }
?>

我用字幕显示新闻标题,但这里只显示一个数据。我想一个接一个地显示所有新闻标题。那么,我该怎么做呢

谢谢你

这是你想要的

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

使用CSS设置新闻广度的样式。如果要使用h3标记,请将其样式设置为:

<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>

h3{
显示:内联;
}

尝试重写代码,以便查询结果显示在您的品牌中。例如,使用您的代码:

<style>
h3 {
   display: inline;
}
</style>


希望这对你有用

因为你只显示了一个结果。在循环中使用显示所有标题。如果我将h3标记放在循环中,那么它将显示所有十个结果,但我希望一个接一个地显示新闻。我用代码回答,请检查下面的内容。元素已过时,不得使用。
<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)) {
                echo '<h3 id="news-h3">'.$fetch['news_title'].'</h3>';
            }
    ?>        
</marquee>