|
Posted by jcage on 11/03/07 11:44
On Nov 2, 9:52 pm, Chris Gorospe <ch...@ekast.com> wrote:
> jc...@lycos.com wrote:
> > On Nov 2, 8:50 pm, Chris Gorospe <ch...@ekast.com> wrote:
> >> jc...@lycos.com wrote:
> >>> I have four fields, "name", "date", "task", and "title" - and am
> >>> trying to PHP code where if I click 'All', all rows for 'Bob' followed
> >>> by all rows in a MySQL datebase for 'Jim' and then all rows for 'Joe'
> >>> would be displayed alphabetically (by name), with all of Bob's rows
> >>> grouped together and then all of Jim's and then all of Joe's, etc
> >>> (versus the way they may reside in the MySQL table).
> >>> My query works well for individual names and also for 'All' but it
> >>> would look and be easier to read if I could group the rows by name and
> >>> maybe list alphabetically. My 'All' code portion currently looks like
> >>> this:
> >>> $query =
> >>> "SELECT *
> >>> FROM $table
> >>> WHERE 1 = 1 ";
> >>> if($name != "All") $query .= "and name = '".$name."'";
> >>> $result = mysql_query($query);
> >>> thanks for any help...
> >>> John
> >> You're probably going to want to use one of the "joins". 'LEFT JOIN',
> >> 'INNER JOIN', etc. Then 'ORDER BY name DESC'. This will give you your
> >> results in alphabetical order.
>
> > Any examples on how to integrate 'join' code for something like this
> > in PHP? Thanks
>
> Actually, you don't even need to use JOIN. I was under the impression
> these people were in different tables.
>
> Just use the 'ORDER BY name DESC' with your 'select *', and that should
> get you want you're looking for.
Hey, that's it... Thank You Sir... Appreciate the help very much. :-)
[Back to original message]
|