Re: Query - Grouping Results
| From: | Jordan Elver | Date: | Mon, 19 Mar 2001 15:02:54 +0000 |
| Subject: | Re: Query - Grouping Results | ||
| References: | 1 | Groups: | php.db php.general |
| Request: | Send a blank email to php-db+get-7595@lists.php.net to get a copy of this message | ||
Sorry, the query works fine, but how do I print it out to the browser so that
it looks like:
John
Dates go here
Bob
Dates go here
Gill
Dates go here
I hope that's clear,
Thanks,
Jord
On Monday 19 March 2001 14:44, you wrote:
> works fine for me.
> what error do you get.
>
>
> -----Original Message-----
> From: Jordan Elver [mailto:jjelver@worldsites.net]
> Sent: Monday, March 19, 2001 2:39 PM
> To: Jeff Armstrong
> Cc: PHP Database Mailing List; PHP General Mailing List
> Subject: Re: [PHP] Query - Grouping Results
>
>
> Doesn't seem to work, how would I print that out with PHP?
>
> On Monday 19 March 2001 13:52, you wrote:
> > how about something like
> > select distinct
> > name,
> > date_format(time, "%W %D %M %Y") as login
> > from
> > users, user_logins
> > where
> > user_logins.user_id = users.id
> > order by name,time
> >
> >
> > -----Original Message-----
> > From: Jordan Elver [mailto:jjelver@worldsites.net]
> > Sent: Monday, March 19, 2001 1:43 PM
> > To: PHP Database Mailing List; PHP General Mailing List
> > Subject: [PHP] Query - Grouping Results
> >
> >
> > Hi,
> > I've got a table like:
> >
> > id user_id ip time
> > 1 2 127.0.0.1 20010316105018
> >
> > Etc, etc.
> >
> > I do a join on the this table and the users table to get the coresponding
> > username to user_id like this:
> >
> > SELECT users.name AS name, user_logins.ip AS ip,
> > UNIX_TIMESTAMP(user_logins.time) AS time FROM users, user_logins WHERE
> > user_logins.user_id = users.id ORDER BY time ASC
> >
> > How can I display the results grouped by username?
> >
> > So, I want to be able to display:
> >
> > Logins for John
> >
> > Thursday 10th
> > Friday 12th
> > Monday 23rd
> >
> > Logins for Bob
> >
> > Monday 1st
> > Tuesday 2nd
> > Saturday 31st
> >
> > Thanks for any help,
> >
> > Jord