Okay I am creating this very simple content management system, and the news system in it isn't working correctly. Anyway, I need a way to show the last 5 articles submitted. So the code I have to do that is:
Code:
$query = "SELECT ID,title,article FROM news ORDER BY ID DESC LIMIT 0,5";
When I click submit, the index page won't show my first article, until I post another article after that. So if I have 4 articles, the 4th article won't show until I post a 5th one, and when I post a 5th one, it won't show until I post a 6th one.. and so on. What could be the problem? And also I don't think I save the form data in the database correctly. Here is the code, is it correct or not?
Code:
$newArticle = "INSERT INTO news (title,category,article) VALUES (".
"'".$HTTP_POST_VARS['title']."',".
"'".$HTTP_POST_VARS['category']."',".
"'".$HTTP_POST_VARS['article']."')";
$result = mysql_query($newArticle);
if (!$result) {
die('Could not load form: ' .mysql_error());
}