Jump to content

Comparing two time/date fields


runnerjp

Recommended Posts

Im trying to set up a script so users can see if any new posts have been in the forum since their last visit to that forum.  The code is below but it always seems to show no new posts even if there is :S

 

General has 1266143084  and last post has 1266143616 ...

 

 

Where am i going wrong>>>

 

$getthreads_result = mysql_query("Select * from forumtutorial_posts where parentid='0' and forum = 'general' ORDER BY lastrepliedto DESC ") or
                                                      die("Could not get threads");

                      $getthreads = mysql_fetch_array($getthreads_result);

                      $getlastpost = mysql_fetch_assoc(mysql_query("SELECT * FROM users WHERE Username = '$username' "));
                       

                      echo "<img src=\"http://www.runningprofiles.com/images/postforum.", (($getlastpost['General'] <= $getthreads['lastrepliedto']) ? "gif" : "jpg"), "\" alt=\"My\" />";

Link to comment
https://forums.phpfreaks.com/topic/192024-comparing-two-timedate-fields/
Share on other sites

A quick look at your code suggests that this line

 

echo "<img src=\"http://www.runningprofiles.com/images/postforum.", (($getlastpost['General'] <= $getthreads['lastrepliedto']) ? "gif" : "jpg"), "\" alt=\"My\" />";

 

should be

 

echo "<img src=\"http://www.runningprofiles.com/images/postforum.". (($getlastpost['General'] <= $getthreads['lastrepliedto']) ? "gif" : "jpg"). "\" alt=\"My\" />";

 

but I would printf such a line like this

 

printf("<img src=\"http://www.runningprofiles.com/images/postforum.%s\" alt=\"My\" />",($getlastpost['General'] <= $getthreads['lastrepliedto']) ? "gif" : "jpg");

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.