moosey_man1988 Posted May 26, 2015 Share Posted May 26, 2015 Hi Guys So basically I've got a page that displays all the notes written for a specific customer and I have managed to get it to display the "customers" date of birth in the correct format when selecting out of the database. but i need to this for a notes list and for some odd reason its displaying a random date at the top of the list but it is displaying the note dates correctly. here is my code: require('database/mysql_connection.php'); //Now Lets grab The Notes from the database using mysql $NoteSelect = "SELECT customerId, note, user, Date FROM notes WHERE customerId='$customerId' ORDER BY Date DESC"; $note_query=mysql_query($NoteSelect); if(mysql_num_rows($note_query)!=0) { $note_rs=mysql_fetch_assoc(); } ?> <!-- This is loading the stylesheet--> <link href="css/crm.css" rel="stylesheet" type="text/css"> <div class="notestable"> <table> <?php if(mysql_num_rows($note_query)!=0) { do { ?> <tr><td><?php echo $note_rs['customerId']; ?></td><td><?php echo $note_rs['note']; ?></td><td><?php echo $note_rs['user']; ?></td><td><?php echo date("d-m-Y H:i:s", strtotime($note_rs['Date']));?></td></tr> <?php } while ($note_rs=mysql_fetch_assoc($note_query)); } else { echo "No results found"; } ?> </table></div> Here is how its displaying Quote Link to comment Share on other sites More sharing options...
Solution Barand Posted May 26, 2015 Solution Share Posted May 26, 2015 '01-01-1970' is what you get when formatting an invalid or 0 date. As the error message states, the fetch_assoc is failing but you still try to output it. if(mysql_num_rows($note_query)!=0) { $note_rs=mysql_fetch_assoc(); } Above is where you call the first row, the function call is missing the argument Quote Link to comment Share on other sites More sharing options...
moosey_man1988 Posted May 26, 2015 Author Share Posted May 26, 2015 Ah so easy! i just thought that was required up there for the rest to work thank you for your help. 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.