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
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>
Try rewriting your code so your query results is displayed within your marque. For example, using your code:
<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>
Hope this works for you!