Jump to content

HOWTO get 'pre' last Field ??


Michael_zz

Recommended Posts

Hiiiiiiiiii everyone  :D

 

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 ?  :confused:

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 :D

Link to comment
https://forums.phpfreaks.com/topic/192794-howto-get-pre-last-field/
Share on other sites

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.