rahulpatel
Programmer
I've been following a tutorial and adapting it to my own needs. I want to display the last article I entered but knowing the code is a bit confusing. Here's what I have at the moment.
I currently have to amend the line in bold to the last article to get it to show. I realise it's going to be pretty simple but I don't know how to do it. Any ideas? Thanks.
Code:
// connect to the database
$conn = dbConnect('admin');
// check for article_id in query string
if (isset($_GET['article_id']) && is_numeric($_GET['article_id'])) {
$article_id = $_GET['article_id'];
}
else {
[B]$article_id = 4;[/B]
}
// prepare SQL query
$sql = "SELECT title, article FROM frontpage WHERE article_id = $article_id";
// process query
$result = mysql_query($sql) or die (mysql_error());
$row = mysql_fetch_assoc($result);
?>
I currently have to amend the line in bold to the last article to get it to show. I realise it's going to be pretty simple but I don't know how to do it. Any ideas? Thanks.