Flames Posted November 4, 2008 Share Posted November 4, 2008 in mysql the default for a date field is 0000-00-00, but i want to check if the date is bigger than that and so has therefore been edited. i tried doing $sql = "SELECT *,DATE_FORMAT(date, '%D %M %Y') AS date2,DATE_FORMAT(edit_date, '%D %M %Y') AS edit_date2,DATE_FORMAT(edit_date, '%D') AS edit_date4 FROM News WHERE name LIKE '%$news%' ORDER BY id ASC"; $result = mysql_query($sql) or die(mysql_error()); echo "News matching search criteria (news title)"; echo "<table border='1'> <tr> <th>ID</th> <th>Title</th> <th>Posted by</th> <th>Posted at</th> <th>Edited at</th> </tr>"; while($row2 = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row2['id'] . "</td>"; echo "<td>" . $row2['name'] . "</td>"; echo "<td>" . $row2['poster'] . "</td>"; echo "<td>" . $row2['date2'] . "</td>"; if($row2['edit_date3'] < 1) { echo "<td> Hasn't been edited </td>"; } else { echo "<td>" . $row2['edit_date2'] . "</td>"; } echo "</tr>"; } echo "</table>"; } but it always shown hasn't been edited Quote Link to comment Share on other sites More sharing options...
rhodesa Posted November 4, 2008 Share Posted November 4, 2008 by the looks of things, you should be testing edit_date4 Quote Link to comment Share on other sites More sharing options...
Flames Posted November 4, 2008 Author Share Posted November 4, 2008 well spotted testing as we speak... thanks for noticing that, it works as intented now. Silly little typos grrrrr Quote Link to comment Share on other sites More sharing options...
rhodesa Posted November 4, 2008 Share Posted November 4, 2008 print_r() is your friend...if it wasn't doing what i was expecting, i would have done: print_r($row); //Added for debugging if($row2['edit_date3'] < 1) then it would have dumped out the values and you would have seen the problem Quote Link to comment Share on other sites More sharing options...
Flames Posted November 5, 2008 Author Share Posted November 5, 2008 kk thanks solved Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.