Mayur Mali Mayur Mali - 1 year ago 46
MySQL Question

How to fetch last login datetime using PHP and MySQL database?

I have 4-5 login record but I want to fetch last login date and time from MySQL database. ex: my last login datetime is 2017-02-03. then how to show or fetch this record from database.login is my field and it's field type is datetime.

Answer Source

You can accomplish it using SQL query. The following is the query you might be looking for:

SELECT * FROM login_history WHERE user_id = 1 ORDER BY login_date DESC LIMIT 1

This is just an example what the query looks like. You can modify it according to the column names you have in the table.

Hope it helps!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download