Hi
I am attempting to build my own cms (although very basic) using php and mysql. Instead of having a static homepage, I want the content displayed to be dynamic. In other words, I want the homepage to be flexible/changeable based on whatever the latest 'content' entry into the database is.
I currently have two tables: 'user', and 'homepage'.
My homepage table is structured as follows:
home_id (int)
user_id (index, fk)
title_cont (varchar)
home_cont (varchar)
home_date (timestamp)
I want to be able to display the latest 'title_cont', and the 'latest home_cont' entry. I am assuming that the date of when an entry is made is going to be useful in order to achieve this, so have included it in the table using a timestamp type.
Here is what I think a solution may be:
<?
$sql = "SELECT * FROM home ORDER BY home_date DESC LIMIT 1";
$display = $db->Execute( $sql );
?>
Then to display on my homepage:
<h2><?=$display->fields['title_cont']?></h2>
<p><?=$display->fields['home_cont']?>
Is this correct? Or is there a better way? Also, should I be using timestamp or datetime?
Thanks