How to display at least 10 data from MySQL Database?
Posted: Sun Nov 14, 2010 10:16 pm
Hi Guys,
Can anyone help me out about displaying 10 data from my database?My codes goes like this. I have 4 fields (id, local_title, local_desc, local_date )
It was arrange by date. If the dates similar it will display in one category. I want to display at least 10 data from my database. But my code doesn't work. Can Anyone help me out?Thanks.
Can anyone help me out about displaying 10 data from my database?My codes goes like this. I have 4 fields (id, local_title, local_desc, local_date )
Code: Select all
<?php
$last_date = "";
$result = mysql_query("SELECT * FROM tbl_localnews ORDER BY local_date DESC");
while ($row = mysql_fetch_array($result)) {
for($i=0; $i<10; $i++){
if ($row['local_date'] != $last_date) {
print("<h2>News for ".date('F j, Y',strtotime($row['local_date']))."</h2>");
$last_date = $row['local_date'];
}
print("<p><b>".$row['local_title']."</b></p>");
print("<p>".$row['local_desc']."</p>");
}
}
mysql_free_result($result);
?>