Page 1 of 1

add pages to results

Posted: Sun Mar 22, 2009 5:01 pm
by killingbegin
Hello all

so i have a table users with some data
lets say that i have 11 users

and 1 2 3

when i am on the first page i want to see the first 5 when i press the 2 i want the 5-10 and on third buttong i want the 11 user

i tried smthing but didnt work i dont want you to solve this but just to help me

i got

that is my code

Code: Select all

 
<link href="style.css" rel="stylesheet" type="text/css" />
<?php
 
$page_res = $_GET['page_res'];
//here im getting what page im gona see but cant go further
if($page_res == 1 || $page_res == "")
{
    $page_res = asd;
}
include("inc/connection.php");
    $res1 = "<b>COUNT(id)</b>";
    $res1 = mysql_query($res1);
    $res1 = mysql_fetch_array($res1); 
    $res1 = $res1[0];
   //i want to see my results by 5 users at every page
    $res1 = $res1 / 5 + 0.8;
    $strquery = "SELECT * FROM users";
    $result = mysql_query($strquery);
    
 
        while($row = mysql_fetch_assoc($result))
        {
            
            $name = $row['name'] ;
            $email = $row['email'];
            $message = $row['message'];
            $date = $row['date'];
            $time = $row['time'];
            
            if($res1 == 4)
            {
                
            }
?>
    <table cellspacing="0" border="0" width="400">
        <tr bgcolor="#CCCCCC" class="bg_name" id="bg_name">
            <td width="100" align="center"><?php echo $name; ?>
            <a href="mailto:<?php echo $email; ?>"><img src="images/mod_email copy.png" width="28" height="15" border="0" /></a>
            </td>
            <td width="100" align="center"></td>
            <td width="100" align="right"><?php echo $date; ?></td> 
            <td width="100" align="center"><?php echo $time; ?></td>    
        </tr>
        
        <tr>
            <td width="400" colspan="4" class="message_bg" height ="50"><?php echo $message; ?></td>
        </tr>
    </table>
 
 
<?php
 
 
        }
 
    
    MYSQL_CLOSE();
//here im showing the paging
    for($i = 1; $i <= $res1; $i++)
    {
        echo '<a href="index.php?page_res= '.$i.'">'.$i.'    </a>';
    }
    
?>
<br>
<form id="form1" name="form1" method="post" action="save_mes.php" class="form">
  <p>
    <label>
      <input name="name" type="text" id="name" value="name" />
    </label>
  <input name="email" type="text" id="email" value="email" />
 
  <p>
    <textarea name="message" id="message" cols="45" rows="5">Write your message</textarea>
  </p>
  <p>
  <input type="submit" name="submit" id="submit" value="Submit" class="buttons" />
  </p>
</form>
 

Re: add pages to results

Posted: Mon Mar 23, 2009 5:04 am
by susrisha
search this forum for the concept called pagination