Michael_zz Posted February 21, 2010 Share Posted February 21, 2010 Hiiiiiiiiii everyone I'm building some big site , and want to make a simple script to "log" any admin that will login to the secured section that contain the main control panel of the site and store some info about him such as when did he login and his ip .. then display a 'record' over the control panel main page to view who was logged in before &when .. I've managed to do this over PHP and MySQL .. but the problem that came up is the record that is displayed on the control panel home page is "my" record not the previous login - as I've logged in just before reading the database, so my data was stored and read as the last data in the table - .. here is the code : $query = "SELECT * FROM table ORDER BY id DESC LIMIT 1 "; $result_set = mysql_query($query, $connection); $logged_login_data = mysql_fetch_array($result_set); $admin_name = $logged_login_data['name']; $ip = $logged_login_data['ip']; So I want to SELECT the field that is just before the last field in the table .. Is this clear ? I've tried to add the " WHERE id = MAX(id)-1 " but sure enough it returns error saying "Invalid use of group function" so I want to know the correct statement to select the 'pre' last field of MySQL database table ?? Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/192794-howto-get-pre-last-field/ Share on other sites More sharing options...
PFMaBiSmAd Posted February 21, 2010 Share Posted February 21, 2010 Use - LIMIT 1,1 Quote Link to comment https://forums.phpfreaks.com/topic/192794-howto-get-pre-last-field/#findComment-1015555 Share on other sites More sharing options...
Michael_zz Posted February 21, 2010 Author Share Posted February 21, 2010 Nice .. that did it thanks Quote Link to comment https://forums.phpfreaks.com/topic/192794-howto-get-pre-last-field/#findComment-1015556 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.