?
Solved

PHP Pagination by Letter

Posted on 2007-12-06
1
Medium Priority
?
1,592 Views
Last Modified: 2008-02-01
Hello!

please see the pagination snippet. It works fine and shows the pagination for all cities within a certain state.

This is a numeric pagination:

0 25  50 75 100 ....

How do I need to change the code to make an alphabetical pagination like this:

Ab - Bc    Bd-Ca    Db - Gi ...

Thanks for help.





<?php
$totalToDo = $numRecords / 25;
 
 
while ($counter < $totalToDo) {
    $pageNumber = $counter * 25;
        if($pageNumber == 0)
        {
        echo '<a href="'. $urlPrefix . $sectionNameLink . '-apstate.html"><b>' . $pageNumber . '</b></a> | ';
        }
        else
        {
        echo '<a href="'. $urlPrefix . $sectionNameLink . '-apstate-' . $pageNumber . '.html"><b>' . $pageNumber . '</b></a> | ';
        }
$counter = $counter + 1;
}
?>
 
...
 
$result = mysql_query("SELECT DISTINCT bizCity FROM biz_aaa WHERE bizState='$bizState' AND bizLive='1' ORDER BY bizCity ASC LIMIT $offset,25");

Open in new window

0
Comment
Question by:seopti
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 11

Accepted Solution

by:
Isisagate earned 1000 total points
ID: 20423205
This should help get you started. You will want to run a query that only returns the results for the set of letters and pass in the letter sets. Then output the returned results...

$letterStart = "Ab";
$letterEnd = "Bc";

$result = mysql_query("SELECT DISTINCT bizCity FROM biz_aaa WHERE bizState='$bizState' AND bizLive='1' and bizCity between  '$letterStart'  and '$letterEnd' ORDER BY bizCity ASC");


0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question