Kineas
11-24-2009, 07:35 PM
I've basically got a blog, and I've implemented versioning, and all of the old blog entries are stored in a seperate table to the latest version of them. I know I could have probably gone around this a different way, but the only unique field in the older versions table is the date_added field.
So when I'm trying to compare between versions, I'm calling entries out of the database based on the date_added field. The format in which the date and time is in is "yyyy-mm-dd hh:mm:ss". I'm passing the date and time through the url and set it as "compare". This is my code:
$comp = $_GET['compare'];
$id = mysql_real_escape_string($comp);
$sql ="SELECT * FROM messagesold WHERE date_added=$id";
$queryResult=mysql_query($sql);
if (mysql_num_rows($queryResult) == 1) {
$dbRecord = mysql_fetch_assoc ($queryResult);
echo "<TABLE bgcolor=\"#3366FF\" width=\"50%\">";
echo "<TR><TD><FONT face=\"Arial\" color=\"white\"><B>".$dbRecord["title"]." - ".$dbRecord['date_added']."</B></FONT></TD></TR>";
echo "<TR><TD bgcolor=\"white\" cellpadding=\"5\"><FONT face=\"Arial\"><P>".$dbRecord["message"]."</p></TD></TR>";
echo "</TABLE>";
When I run this, it gives an error, which I can get rid of by taking the space and :'s out of the time and date, and by manually changing the format in the database. But it doesn't show any results. I've even gone into phpmyadmin and copy and pasted the data saved in date_added and typed in the command line SELECT * FROM table WHERE date_added= and it says there's no results.
Any help would be great thanks.
So when I'm trying to compare between versions, I'm calling entries out of the database based on the date_added field. The format in which the date and time is in is "yyyy-mm-dd hh:mm:ss". I'm passing the date and time through the url and set it as "compare". This is my code:
$comp = $_GET['compare'];
$id = mysql_real_escape_string($comp);
$sql ="SELECT * FROM messagesold WHERE date_added=$id";
$queryResult=mysql_query($sql);
if (mysql_num_rows($queryResult) == 1) {
$dbRecord = mysql_fetch_assoc ($queryResult);
echo "<TABLE bgcolor=\"#3366FF\" width=\"50%\">";
echo "<TR><TD><FONT face=\"Arial\" color=\"white\"><B>".$dbRecord["title"]." - ".$dbRecord['date_added']."</B></FONT></TD></TR>";
echo "<TR><TD bgcolor=\"white\" cellpadding=\"5\"><FONT face=\"Arial\"><P>".$dbRecord["message"]."</p></TD></TR>";
echo "</TABLE>";
When I run this, it gives an error, which I can get rid of by taking the space and :'s out of the time and date, and by manually changing the format in the database. But it doesn't show any results. I've even gone into phpmyadmin and copy and pasted the data saved in date_added and typed in the command line SELECT * FROM table WHERE date_added= and it says there's no results.
Any help would be great thanks.