Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Sep 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation pagination with a alphabetica search filter?

    How would i use my current pagination code with a alphabetica search filter. what i mean by this is I want people to select from a row that looks like "ALL A B C D E F G H I J K L M N O P Q R S T U V W X Y Z #" and when they click on one they only get the Letter they selected from the search results.

    so if i selected "a" i would get "aa" then "ab" and so on and if i selected "s" i would get "sa" "sb" "sc" and so on again.
    I have seen other people do it but I think its just ordering and spliting the results.

    Thanks for your time. I really don't know why i can't find out where or how to do this but please help me the code i am using is below.

    PHP Code:
    <?php  include 'db.inc.php'$per_page 6;  $pages_query mysql_query("SELECT COUNT(`id`) FROM `anime`"); $pages ceil(mysql_result($pages_query0) / $per_page);  $page = (isset($_GET['page'])) ? (int)$_GET['page'] : 1$start = ($page 1) * $per_page;  $query mysql_query("SELECT `title`, `year`, `episodes`, `url`  FROM `anime`  ORDER BY `title` ASC LIMIT $start, $per_page ");   if($query === FALSE) {     die(mysql_error()); // TODO: better error handling }  include_once("includes/overall/header.php");  ?> <div id="sidebar1"> </div> <div id="middlepage"> <div style=" padding:2px;"> <table id="animetable"> <tr> <tr>   <th>Title</th>   <th>Year</th>   <th>Episodes</th> </tr>   <?php while($query_row mysql_fetch_assoc($query)) { echo '<td><a href="',$query_row['url'],'">'$query_row['title'] ,'</a></td><td>'$query_row['year'] ,'</td><td>'$query_row['episodes'] ,'</td></tr><tr>'; }  ?> </tr> </table> <?php if($pages >= && $page <= $pages){     for ($x=1$x<=$pages$x++){         echo ($x == $page) ? '<strong><a href="?page='.$x.'">'.$x.'</a></strong> ' '<a href="?page='.$x.'">'.$x.'</a> ';     } } ?> </div>   <?php include_once("includes/overall/footer.php"); ?>

  • #2
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    2,958
    Thanks
    2
    Thanked 304 Times in 296 Posts
    The WHERE clause you are forming now for your letter search would need to be formed in a php variable. You would add that variable into each of the query statements.

    You would also need to form the pagination links with both the page=x and your search=y attributes.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #3
    New to the CF scene
    Join Date
    Sep 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    PHP Code:
    <?php 
    include 'db.inc.php';
    $per_page 6;

    $pages_query mysql_query("SELECT COUNT(`id`) FROM `anime`");
    $pages ceil(mysql_result($pages_query0) / $per_page);

    $page = (isset($_GET['page'])) ? (int)$_GET['page'] : 1;
    $start = ($page 1) * $per_page;

    $query mysql_query("SELECT `title`, `year`, `episodes`, `url` 
    FROM `anime` 
    ORDER BY `title` ASC
    LIMIT $start, $per_page "
    );


    if(
    $query === FALSE) {
        die(
    mysql_error()); // TODO: better error handling
    }

    include_once(
    "includes/overall/header.php"); 
    ?>
    <div id="sidebar1"> </div>
    <div id="middlepage">
    <div style=" padding:2px;">
    <table id="animetable">
    <tr>
    <tr>
      <th>Title</th>
      <th>Year</th>
      <th>Episodes</th>
    </tr>
      <?php while($query_row mysql_fetch_assoc($query)) {
    echo 
    '<td><a href="',$query_row['url'],'">'$query_row['title'] ,'</a></td><td>'$query_row['year'] ,'</td><td>'$query_row['episodes'] ,'</td></tr><tr>';

    ?>
    </tr>
    </table>
    <?php
    if($pages >= && $page <= $pages){
        for (
    $x=1$x<=$pages$x++){
            echo (
    $x == $page) ? '<strong><a href="?page='.$x.'">'.$x.'</a></strong> ' '<a href="?page='.$x.'">'.$x.'</a> ';
        }
    }
    ?>
    </div>
      <?php include_once("includes/overall/footer.php"); ?>


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •