Paging Help

Discussion in 'PHP' started by rakhe, Sep 12, 2009.

  1. #1
    hello frnds this is my website http://www.sms2friends.co.cc...in my website there are some catgories on left side..when i click on first category the content of annivesery sms categry display on middle column with paging...but my paging function is not working properly...i want 5 joke per page.. 5 joke are disply and paging script also running but whn i clik on seconday page of my paging script..its not working..
    please chk my code and help me

    <table id="table_main">
    <tr>
    <td width="17%" valign="top">
    <table id="side">
    <tr><td><?php
    mysql_connect("localhost","root","vertrigo");
    mysql_select_db("sms");
    $result = mysql_query("SELECT * FROM categories");
    while($row=mysql_fetch_array($result))
    {
    echo "<a href='index.php?app=1'>".$row['anniversary']."</a>";
    echo "<br />";
    echo "<a href='index.php?app=2'>".$row['birthday']."</a>";
    echo "<br />";
    }
    ?></td></tr></table></td>
    <td width="66%" valign="top"><table id="side">
    <tr>
    <td><?php
    switch($_GET['app'])
    {
    case 1:
    $page = $_GET['page']; // Set the Page From the Get Parameter
    if(!isset($page))
    {
    $page = 1; // If Get Parameter not set then make $page to 1!
    }
    $posts = 5; // How many Posts on one Page
    $start = $page * $posts - $posts; // Calculate the start Page!
    $result = mysql_query("SELECT id FROM anni");
    $how_much = mysql_num_rows($result);
    $how_much = $how_much / $posts; // How many Pages altogether
    $result =mysql_query("SELECT * FROM anni LIMIT $start, $posts"); // Select the fields from
    while($row = mysql_fetch_array($result))
    {
    echo $row['msg'];
    echo "<br>";
    echo $row['date']." ".$row['name'];
    echo "<hr>";
    }
    break;

    case 2:
    $result = mysql_query("SELECT * FROM birthday");
    while($row=mysql_fetch_array($result))
    {
    echo $row['msg'];
    echo "<br>";
    echo $row['date']." ".$row['name'];
    echo "<hr />";
    }
    break;

    default:

    }

    ?></td>
    </tr>
    <tr>
    <td><?php
    for($a=0; $a < $how_much; $a++) // The paging function
    {
    $b = $a + 1;
    if($page == $b)
    {
    echo "<b><u>$b</u></b>"; // If the selected Page the same as the current Page then it make the number bold!
    }
    else
    {
    echo " <a style=\"color:000000\" href=\"index.php?page=$b\">$b</a>&nbsp;"; // The Links for the Pages
    }
    }
    ?></td>
    <td></td>
    </tr>
    </table>
    </td>
    <td width="17%" valign="top"><table id="side">
    <tr><td>asdfasd</td></tr></table></td>
    </tr></table>


    PLEASE CHK THE LINKING OF PAGING THERE IS A PROBLEM.....IF CHANGE LINKING THIS echo " <a style=\"color:000000\" href=\"index.php?page=$b\">$b</a>&nbsp;"; TO
    <a style=\"color:000000\" href=\"index.php?app=$_GET['app']&page=$b\">$b</a>
    I AM GETTING ERROR
     
    rakhe, Sep 12, 2009 IP
  2. mayz

    mayz Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I will recommend you check some pagination scripts at http://www.1afm.net/scripts/indexf.php
    See under the Pagination category.
    Hope that helps you.
    Mayz
     
    mayz, Sep 13, 2009 IP