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 Support
One 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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php