SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Guru mmarif4u's Avatar
    Join Date
    Dec 2006
    Location
    /dev/swat
    Posts
    619
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Simple searching with pagination

    Hi guys.
    I have a little problem in pagination of searching script.
    The following are the form code:
    PHP Code:
    <form method='get' action=''>
    <
    input type='text' name='search'>
    <
    input type='submit' name='submit' value='Search'>
    </
    form
    The following are the php code for searching:
    PHP Code:
    <?php
    if($_GET['submit']){
    $rowsPerPage10;
    $pageNum 1
    if(isset(
    $_GET['page'])) { $pageNum $_GET['page']; }
    $offset = ($pageNum 1) * $rowsPerPage;      
      echo 
    "Results";
      echo 
    '<br>';
    $sql2="select * from courses_add where courses_add like '%$search%' LIMIT $offset$rowsPerPage ";
    $select2=mysql_query($sql2);
    $numrows2=mysql_num_rows($select2);    
    echo 
    "Your search keyword return ".$numrows2." results";
    echo 
    '<br>';echo '<br>';
    $query_count "SELECT COUNT(*) AS page_count_rows FROM courses_add where courses_add like '%$search%'";
    $result_count mysql_query($query_count) or die(mysql_error());
    $row_count mysql_fetch_array($result_countMYSQL_ASSOC);
    $page_count_rows $row_count['page_count_rows'];

    $maxPage ceil($page_count_rows/$rowsPerPage);
    if(
    $maxPage>200){
    $maxPage 200;
    }
    $self $_SERVER['PHP_SELF']; $nav_page '';         
        while(
    $row2=mysql_fetch_object($select2)){
        
    $term1=$row2->courses_add;
        
    $c_id=$row2->c_id;     
        echo 
    $term1;
        echo 
    '<br>';
    }
    }
    ?>
    <br>
                <?php
                
    if ($page_count_rows>10){
                    
    ?>
                <table align="center" border="0" cellpadding="0" cellspacing="0" width="95%">
               <tr>
                <td><hr noshade color="#6699FF" align="left" width="100%" size="1"> </td>
              </tr>
              <tr>
                <td align="center">
                <?php             
                  
    include('paging.php');
                
    ?>
               </td>
              </tr>
              </table><br>
               <?php ?>
    Now the problem is if click the next link suppose it have to go to 2nd page, it works but i did not see any
    data there.
    I work out on this last night but no luck.
    Can any one give some helpful hints.
    Thanks in advance.

  2. #2
    SitePoint Guru mmarif4u's Avatar
    Join Date
    Dec 2006
    Location
    /dev/swat
    Posts
    619
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Solved!!!


Bookmarks

Posting Permissions

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