Hey guys. I got a news system, but i dont know how to make it so it shows the latest news FIRST. It shows them last lol... $query = "SELECT id, title, author, post, DATE_FORMAT(date, '%M %d, %Y') as sd FROM news_posts"; $result = @mysql_query($query); if ($result) { while ($row = mysql_fetch_array($result, MYSQL_ PHP: Thats the code. Can someone show me how to make it so it shows the latest news first and the oldest last. O and i need it to only show 6 news posts. If anyone can do that ill give green rep.. - Prilep
I think this should work. $query = "SELECT id, title, author, post, DATE_FORMAT(date, '%M %d, %Y') as sd FROM news_posts ORDER BY date DESC"; PHP:
Yes! That worked thanks. Do you know how to make it so it only shows 6 news posts. I gave you green rep for that post ill give you another one if you can figure that out. - Prilep
$query = "SELECT id, title, author, post, DATE_FORMAT(date, '%M %d, %Y') as sd FROM news_posts ORDER BY date DESC LIMIT 6" PHP:
Thanks, that worked great! For some reason i cant give you rep again. I have to wait and give some other person rep and then i will give you. Thanks - Prilep
GIVING GREEN REP IF YOU SOLVE THIS! Ok i have a new problem. I added an image because i want an image on my news like for what the news is for but i just cant get it to show <?php include ('mysql_connect.php'); $query = "SELECT id, title, avatar, author, post, DATE_FORMAT(date, '%M %d, %Y') as sd FROM news_posts ORDER BY date DESC LIMIT 2"; $result = @mysql_query($query); if ($result) { while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $url = 'comments.php?id='.$row['id']; echo ' <div id=/"right/"> <img src=\"'.$row['avatar'].'\" style=\"border: 1px dashed #1079D6\" width=\"70\" height=\"70\"></a> <div id=/"maincontent/"> <h3><font size="1" face="Verdana">'.$row['title'].' Ãà ïèøà Ãî Ãa: '.$row['sd'].'</font></h3><br /> Posted by : <b>'.$row['author'].'</b><br /> '.$row['post'].'<br /> <a href="javascript:openComments(\''.$url.'\')">Add new comment or view posted comments</a></p>'; } } else { echo 'There are no news posts to display'; } ?> PHP: See everything is showed with '.$row['title'].' but i cant get the avatar to show. Maybe avatars dont show like that?? im confused.. this is what i use for the avatar but its not showing. It gets submited into the database but dosent show <img src=\"'.$row['avatar'].'\" style=\"border: 1px dashed #1079D6\" width=\"70\" height=\"70\"></a> PHP: - Prilep
<div id=/"right/"> <img src=\"'.$row['avatar'].'\" style=\"border: 1px dashed #1079D6\" width=\"70\" height=\"70\"></a> <div id=/"maincontent/"> <h3><font size="1" face="Verdana">'.$row['title'].' Ãà ïèøà Ãî Ãa: '.$row['sd'].'</font></h3><br /> Posted by : <b>'.$row['author'].'</b><br /> '.$row['post'].'<br /> HTML:
post what you get when you try running it right click ->view source and the part with <img src ... by the way the </a> at the end is not needed I guess
<img src=\"\" style=\"border: 1px dashed #1079D6\" width=\"70\" height=\"70\"></a> <div id=/"maincontent/"> HTML: where it says src i just cant get it so it gets the image link... thats my problem thanks - Prilep
are you sure it has a value stored in it ? why don't you just echo the results like : echo 'image : '.$row["avatar"].' <br> any other values that you want to test'; PHP:
OK then final thing : are you sure that the cell name is spelled correctly and it has a value in it ?
By value I think he means, is there actually something in it? Like if I stored "http://www.mysite.com/avatar.jpg", that would be the value in the field. To me it looks like you dont actually have a URL stored in that field of the DB, hence you are getting an empty string back. Can you look at the database using something like phpmyadmin to see if there is actually anything there?
Yep there is. I just need it to show. I checked in PHPmyadmin and everything is inserted, but its just not showing ... - Prilep
That just cannot be ... fix the table to make sure there's nothing wrong with it (repair). That's the best I can do ... an avatar field can't just be blank with no reason at all.