Re: Re: A stupid question...
| From: | liljim | Date: | Mon, 11 Mar 2002 09:08:33 +0000 |
| Subject: | Re: Re: A stupid question... | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-87976@lists.php.net to get a copy of this message | ||
Hi chuck,
use left()
assuming your column is called "name", then something like this will do:
$letter = "a";
$get = @mysql_query("SELECT * FROM table WHERE LEFT(surname, 1) = '$letter'
ORDER BY surname ASC");
That should get out all of the fields beginning with a or A and list them
alphabetically.
Hope that's of some help.
James
"Chuck "Pup" Payne" <cepayne@magidesign.com> wrote in message
news:B8B188BB.C826%cepayne@magidesign.com...
> I want to sort by a letter in a colomn. Let say I want to sort the colomn
> last_name. I can do order by but I can do just the A's.
>
> http://www.myserver.com/mysort.php?Letter=A
>
> Like to create a link on a web "A" then sort only the last name are A.
>
> I hope that's helps. I can order by, but I can't so a sort like the
example
> above.
>
> Chuck Payne
> Magi Design and Support
>
>
> > on 3/10/02 9:42 PM, Cary at cary@Ali-Co.com wrote:
> >
> >> At 08:24 PM 3/10/02, Chuck \"PUP\" Payne wrote:
> >>> Hi,
> >>>
> >>> I not a newie but I am not a pro at mysql either. I want to do a query
by
> >>> letter(a, b, c..ect.). Is there a simple way to do it. I am writing in
PHP.
> >>> So can someone please so me the how.
> >>
> >>
> >> I'm not totally sure what your looking for. If you could elaborate a
little
> >> I am sure that one of us could help you out.
> >>
> >> Cary
> >>
> >>
> >>
> >
>