SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member segfault's Avatar
    Join Date
    Oct 2003
    Location
    Melbourne
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy Can't Add Page Numbers!

    I just need to know how can i add pages to the bottom of the page. For example if i have 50 records in the database recipe.....how can i display 10 records on each page....Don't know how to get around it.I know that i have to mysql_num_rows & a for loop but can't figure it out.

    Here is the code...
    PHP Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <?php
    include('dblogin.php');
    ?>
    <html>
        <head>
        <title>Welcome to India online ! Administration</title>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">    
             <link rel="stylesheet" href="css/Style1.css" type="text/css">    
        </head>    
        <div id="backgroundtable">
        <table class="headertable">        
              <tr valign="bottom">
                 <td>             
                      <img src="images/heading.gif" alt="India Heading">
             </td>
             <td align="right">    
                      <form name="search" method="post" action="">
                   <input type="text" value="Keyword/Phrase" name="searchfield" size="15" class="searchtext">
                   <input type="submit" name="searchbutton" value="Search" class="searchbutton">
                    </form>
                <?php
                
    echo"<p class=datepara>";
                    echo( 
    date("l, F dS Y") );
                echo
    "</p>";
                    
    ?>    
             </td>
               </tr>      
            </table>
            <table class="bodytable">
            <?php
                $cxn 
    = @ConnectToDb($dbServer$dbUser$dbPass$dbName);
                
    $sql=@mysql_query("SELECT * FROM RECIPE");    
                if(!@
    mysql_query($sql))
                {
                    echo(
    "<p class=bodypara>These are the recipes in the database</p>");
                }
                else
                {
                    echo(
    "<p class=bodypara>Error Performing Query !</p>");
                }
            
    ?>
            <table align=center bgcolor="#212121" border=1 cellpadding=0 cellspacing=0>
            <tr>
                   <td><p class="bodypara"> Serial Number </p></td>
                   <td><p class="bodypara"> Recipe Name </p></td>
                    <td><p class="bodypara"> Recipe Description </p></td>
            </tr>
            <?php
                   
    while($row mysql_fetch_array($sql))
                {
                  echo(
    "<tr>");     
                  echo(
    "<td><p class=bodypara>".$row["id"]."</p></td>");
                  echo(
    "<td><p class=bodypara>".$row["name"]."</p></td>");
                  echo(
    "<td><p class=bodypara>".$row["description"]."</p></td>");
                  echo(
    "</tr>");              
                }                              
            
    ?>
            <tr>
              <td align="center" colspan="3"><a href="adminfunction.php">Administration Page</a></td>
            </tr>                 
            </table>
            <hr class="whitehr">             
        </div>            
    </html>
    Thanx for the help..
    <!--A tree is not a tree if it is a Rock! -->

  2. #2
    masquerading Nick's Avatar
    Join Date
    Jun 2003
    Location
    East Coast
    Posts
    2,215
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm this wouldn't work as it is, but it should give you an idea. Might not be the most efficient way:

    SELECT * FROM $TableName LIMIT = '$limit1, $limit2'

    Have an if statement in case the $limit is not set (like when they first view the page)

    if(!isset($limit1)) { $limit = 0 }
    if(!isset($limit2)) { $limit = 10 }

    Then for the links have something like this:

    $next1 = $limit + 10
    $next2 = $limit + 10

    <a href="page.php?limit='$next', '$next2'">View Page 2</a>

    That is, to say the least, a somewhat sloppy way to do it, and as it is right now would probably produce some parse errors.


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
  •