Jump to content

Date Format within list


moosey_man1988
Go to solution Solved by Barand,

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
Share on other sites

  • Solution

'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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.