Reputation: 2066
how can i get mysql results with alphabetical pagination i.e i have 2 fields i.e id and name in mysql table and following html links for pagination
A B C D E F G .......
by clicking on A i want to get results names starting with A
how can i do that with php
Upvotes: 0
Views: 1813
Reputation: 164910
Use a query like
SELECT `id`, `name` FROM `table` WHERE `name` LIKE :index
Then, bind :index
to something like sprintf('%s%%', $selectedIndex)
It would also be a good idea to create an index on the name
column.
Upvotes: 1
Reputation: 163288
Use SQL LIKE
syntax:
SELECT * FROM tablename WHERE name LIKE 'A%'
Upvotes: 3