At 4:30 PM +0100 7/15/09, Ashley Sheridan wrote:
On Wednesday 15 July 2009 16:21:22 tedd wrote:
 At 12:38 PM -0700 7/14/09, Miller, Terion wrote:
 >I am trying to make a page that displays a-z like a b c d e etc as links
 >then when you click open one it reloads itself and shows only the query
 >results that go with that letter...i'm not getting it....I get a page that
 >says ARRAY over and over...
 >What I have so far:


 Why not have MySQL sort the data instead of using php?

 For example (from memory -- use with caution)

 SELECT name FROM restaurant ORDER BY name DESC LIMIT $offset, 1

 Then just change the offset to go up and down the list.



You could do what Tedd suggested, but use MySQL to actually limit the results
it returns you by using a like clause, i.e. WHERE `somefield` LIKE 'a%'.

*ducks to avoid people throwing things at him. I know it's slow!*



My solution on this is simply to sort all the names and then pull them out one by one depending upon where they appear in the sort. I don't really see the need for LIKE to do this unless the user is entering a guess. In such case, then you want to provide them with your best fit.

Here's an example of both:

The user can step through the database, which is initially sorted on last name. If the user picks to sort on email, then the sort is done as per email. In both cases, the data is stepped through sequentially (Alphabetical pagination) by using an offset and limit combination.

However, if the user clicks on an alphabetical tab, then I use a LIKE to place them (their pagination) at the position of that sort at that character. That's where a LIKE would work well.




PHP General Mailing List (
To unsubscribe, visit:

Reply via email to