PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
daebat
Forum Commoner
Posts: 47 Joined: Mon May 11, 2009 10:16 am
Post
by daebat » Fri Feb 19, 2010 2:12 pm
I need for the following to only post the first 5 listings and not all of them. How can I modify this to make it work?
Code: Select all
<?php
$data = mysql_query("SELECT post_date, post_title, post_status, post_type FROM wp_posts ORDER BY post_date ASC ") or die(mysql_error());
//Puts it into an array
while($info = mysql_fetch_array( $data ))
if($info['post_status'] == 'publish'){
if($info['post_type'] == 'post'){
echo"<li>".$info['post_title'] . "</li>";
}
else{
}
}
else{
}
?>
flying_circus
Forum Regular
Posts: 732 Joined: Wed Mar 05, 2008 10:23 pm
Location: Sunriver, OR
Post
by flying_circus » Fri Feb 19, 2010 2:18 pm
daebat wrote: I need for the following to only post the first 5 listings and not all of them. How can I modify this to make it work?
Code: Select all
$data = mysql_query("SELECT post_date, post_title, post_status, post_type FROM wp_posts ORDER BY post_date ASC LIMIT 5") or die(mysql_error());
daebat
Forum Commoner
Posts: 47 Joined: Mon May 11, 2009 10:16 am
Post
by daebat » Fri Feb 19, 2010 2:23 pm
haha thanks. i JUST found this as soon as you posted.