开发者

how can i get mysql results with alphabetical pagination

how can i get mysql results with alphabetical pagina开发者_C百科tion 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


Use SQL LIKE syntax:

SELECT * FROM tablename WHERE name LIKE 'A%'


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜