Printing out usernames and logins
| From: | Jordan Elver | Date: | Mon, 14 May 2001 17:35:24 +0000 |
| Subject: | Printing out usernames and logins | ||
| Groups: | php.db php.general | ||
| Request: | Send a blank email to php-db+get-9289@lists.php.net to get a copy of this message | ||
Hi,
I'm trying to print out a list of usernames and the times they logged in.
I want to print it out like:
joe
fred
frank
Then when you click on one of the names it show just there login times, like
this, so if I click on fred it prints out:
joe
fred
- <login time>
- <login time>
- <login time>
frank
But it doesn't continue printing out the rest of the usernames after it's
finished printing freds logins.
Any ideas would be appreciated.
The code seems to have something to do with the second query, I think :-(
The code I'm using is below.
Thanks,
Jord
db_connect();
$sql = "SELECT id, username FROM users";
$result = @mysql_query($sql);
if(@mysql_num_rows($result) > 0) {
echo'This is a list of Members who have Logged In to their account with
times and dates:<BR><BR>';
while(list($id, $username) = mysql_fetch_array($result)) {
echo"<A
HREF=\"$PHP_SELF?user=$username&id=$id\">$username</A><BR>\n";
if($username == $user) {
$sql = "SELECT UNIX_TIMESTAMP(time) AS time FROM user_logins
WHERE user_id = $id ORDER BY time DESC";
$result = @mysql_query($sql);
while(list($time) = mysql_fetch_array($result)) {
echo date('h:i a l d F', $time)."<BR>\n";
}
}
}
} else {
echo error('No one has Logged In yet!');
}