Re: Re: A stupid question...
| From: | michael kimsal | Date: | Mon, 11 Mar 2002 04:16:35 +0000 |
| Subject: | Re: Re: A stupid question... | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-87951@lists.php.net to get a copy of this message | ||
Chuck "Pup" Payne wrote:
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 SupportOne of two things to do: When you're inserting the data, figure out the first letter and store that as a separate column ("letter" perhaps) Second, probably easier to implement in your case with existing data, is to use LIKE. $sql = "select * from datatable where last_name like '$letter%'"; The % is a wildcard symbol, so if $letter is "a" then a last name of "adams", "aames", "aston", etc. would all match. I know there's someway to have mysql do a string manipulation to compare just part of a column's data with something, so you could do something similar to a 'substr' in PHP - but it's late and I can't remember off the top of my head. Hope that helps... -------------------------- Michael Kimsal http://www.phphelpdesk.com Taking the ? out of <?php 734-480-9961