Pennimus
02-02-2006, 10:20 PM
In looking to code a blog with comments, I've been told that the best way is to use associated tables, with one for the actual blog and one for the comments.
Firstly, is this in fact the best way, and if so can anybody point me to a good summary/discussion/tutorial on associated tables?
EDIT: Another question. I'm using this query to pull the blog entry out of the database, which is working fine:
$blog = mysql_query ("SELECT title, content, date FROM `blog` ORDER BY `date` DESC LIMIT 10") or die(mysql_error());
However the resulting date isn't particularly user friendly, reading 2006-02-02 or similar. I'd like it instead to say 'February 2nd 2006'
I attempted to use this tutorial (http://www.wsworkshop.com/php/php-mysql-weblog.html) which advised using this format to convert the date on the fly -
$query ="SELECT entrytitle, entrytext,";
$query.=" DATE_FORMAT(entrydate, '%M %d, %Y') AS date";
$query.=" FROM weblog ORDER BY entrydate DESC LIMIT 10";
However that resulted in an error - unexpected ';' on line 9 (which is the first semi colon in the above code) so evidently that's not a good way of approaching this.
I understand the actual date formats just not how to convert them as they come out of the database. Anyone got any ideas?
Firstly, is this in fact the best way, and if so can anybody point me to a good summary/discussion/tutorial on associated tables?
EDIT: Another question. I'm using this query to pull the blog entry out of the database, which is working fine:
$blog = mysql_query ("SELECT title, content, date FROM `blog` ORDER BY `date` DESC LIMIT 10") or die(mysql_error());
However the resulting date isn't particularly user friendly, reading 2006-02-02 or similar. I'd like it instead to say 'February 2nd 2006'
I attempted to use this tutorial (http://www.wsworkshop.com/php/php-mysql-weblog.html) which advised using this format to convert the date on the fly -
$query ="SELECT entrytitle, entrytext,";
$query.=" DATE_FORMAT(entrydate, '%M %d, %Y') AS date";
$query.=" FROM weblog ORDER BY entrydate DESC LIMIT 10";
However that resulted in an error - unexpected ';' on line 9 (which is the first semi colon in the above code) so evidently that's not a good way of approaching this.
I understand the actual date formats just not how to convert them as they come out of the database. Anyone got any ideas?