help with my date login function. SQL command problem
Posted: Sat Dec 10, 2011 5:35 am
hi everyone
i have written a function that give the login date each time registred members log onto the site.
The function works; i.e it records the exact time/date that a member logs onto the site . Thus if a member logs into the site 20 times it will log 20 dates of logins for that member. the function works perfectly.
The problem however occurs when i then try to display the last login date of a member on the 'membership galllery page,.
My incorrectly drafted sql command is causing the script to draft a gallery page for each time the user logged onto the site. however , i only need the last logindate of the user.
it might help if i show you my script
The above script works .However, it produces a seperate entry for each time the user logged into the site. i however only need it to produce the last entry for the user. i tried to impliment a MAX fucntion but it did not work
below is how i tried to resolve the problem. i amened the SELECT statement to include a max function. it did not work however.
please how do i amend my statment to only retrive the last login date from every user.
warm regards
Andreea 115
i have written a function that give the login date each time registred members log onto the site.
The function works; i.e it records the exact time/date that a member logs onto the site . Thus if a member logs into the site 20 times it will log 20 dates of logins for that member. the function works perfectly.
The problem however occurs when i then try to display the last login date of a member on the 'membership galllery page,.
My incorrectly drafted sql command is causing the script to draft a gallery page for each time the user logged onto the site. however , i only need the last logindate of the user.
it might help if i show you my script
Code: Select all
<?php
$select = " SELECT u.first_name,
lo.logindate ";
$from = " FROM
users u LEFT OUTER JOIN logindate lo
ON u.user_id = lo.user_id
$where = " WHERE
u.membership_type = 'Active' ";
$order= "ORDER BY u.user_id ASC LIMIT $start, $display ";
$query = $select.$from.$where. $order ;
?>
below is how i tried to resolve the problem. i amened the SELECT statement to include a max function. it did not work however.
Code: Select all
<?php
$select = " SELECT u.first_name,
MAX(lo.logindate)logindate ";
?>
warm regards
Andreea 115