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'.
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 );
But then I cam across the other approach - which looks a little unusual to me i.e
...I'm not familiar with using "<?=" instead of "echo" or "print". Is it an OO approach?
Try as I have done to pick up OO PHP, I have found it impossible to learn on my own (without having £££ to spend on Zend Training etc) so I have reverted to traditional methods...
The benefit of using DateTime is that you can perform actions on the data in the query, MySQL has a host of functions that will work on DateTime fields.
If you really need the date as a Unix timestamp, then there is a MySQL function to convert DateTime to a timestamp, and also PHP has a function that will do the same.
As for <?=, it is simply shorthand for <?php echo.... It should not be used on projects that will, or could, be deployed on unknown configurations, as it requires the PHP short tags option to be enabled.