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 Link to comment https://forums.phpfreaks.com/topic/296487-date-format-within-list/ Share on other sites More sharing options...
Barand Posted May 26, 2015 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 Link to comment https://forums.phpfreaks.com/topic/296487-date-format-within-list/#findComment-1512634 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. Link to comment https://forums.phpfreaks.com/topic/296487-date-format-within-list/#findComment-1512643 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.