开发者

how can i get mysql results with alphabetical pagination

开发者 https://www.devze.com 2023-01-21 23:18 出处:网络
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

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

精彩评论

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