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