I got a problem while I'm trying to retrieve data from db!
Here's my parsing code that I've included & will get the data from MySQL table:
$select_posts = "select * from posts order by RAND() LIMIT 0,6";
$run_posts = mysqli_query($con,$select_posts);
while($row=mysqli_fetch_array($run_posts)){
$post_id = $row['post_id'];
$post_title = $row['post_title'];
$post_date = $row['post_date'];
$post_author = $row['post_author'];
$post_image = $row['post_image'];
$post_keywords = $row['post_keywords'];
$post_content = $row['post_content'];
$post_summary = $row['post_summary'];
}
As you can see I add the LIMIT 0,6
which means "Starts from 1st row & show 6 items from table"...
But I don't know why only 1 result appears.
This is the page that I show results of my table:
<div id="box">
<div class="BJadidBold">
<?php
if (mysqli_num_rows($run_posts) > 0){
echo "
<h1>$post_title</h1>
<p>$post_summary</p></br>
<a style='float:right;font-size:30px;margin-top:-30px;' href='blog_post_content.php?post_id=$post_id'>readmore</a>
";
}else{
echo "<h1>No posts yet!</h1>";
}
?>
</div>
</div>
I want to show at least 6 items on my page. How can I be able to do that?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…