Jump to content

Date Format within list


moosey_man1988

Recommended Posts

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
post-178672-0-26933400-1432634170_thumb.png
Link to comment
https://forums.phpfreaks.com/topic/296487-date-format-within-list/
Share on other sites

'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

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.