Jump to content

[SOLVED] displaying the last updated entry


shadiadiph

Recommended Posts

Hi I have a small problem I have tried numerous ways but can't get it to work.

I have the following script as the head to select from my database there is a dtUpdatedOn column in tbleexdetails how do i get it to display the last updated row in the table?

 

 

 

$treid = $_GET["tid"];

$sql = "select * from tblexdetails where intexID='$treid'";

$temps=$DB_site->query($sql);

if($row=$DB_site->fetch_array($temps))

 

 

This has been driving me nuts for 3 days now i have tried using order by many things but can't seem to get anything to work any hints would be most appreciated Thank you

 

 

 

Link to comment
Share on other sites

While there may be a way to do it with your date formatted that way, I don't know it myself, so I can't help you with that. But I can give you an alternative suggestion that I use. I keep all timestamps in my database as unix timestamps - the number of seconds since jan 1, 1970. You can get this using time() and mktime(). Then when you want to check the most recently updated row, you can use:

 

"SELECT row_id FROM tblexdetails  ORDER BY row_id DESC LIMIT 1"

Link to comment
Share on other sites

I just made up 'row_id'. Change it to whatever the column name is of the data you want to get from the database. If there is more than one column name, separate them by commas.

 

Or you could use * like you were before, but thats not very good programming.

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.