ive already search in google and yahoo but i don't know how to add that code to my code.

here's my code in displaying a data in the table

$result = mysql_query("SELECT * FROM rent where status = 'pending' order by cno asc");
$count = mysql_num_rows($result);

<table border='1' cellspacing='0' width='612'>
   	<tr>
	<th colspan='8' bgcolor="#000000"><font color='#00FF00'>PENDING REQUEST</font></th>
	</tr>
      <tr>
  		 
      <th bgcolor='green'><font color='white'>
   
      <input type='checkbox' name='checkall' onclick='checkedAll();' />
   
      </font></th>
   
      <th bgcolor='green'><font color="white">ID</font></th>
 	<th bgcolor='green'><font color='white'>Book Date</font></th>
      <th bgcolor='green'><font color='white'>Check In</font></th>
 
      <th bgcolor='green'><font color='white'>Check Out</font></th>
  
      <th bgcolor='green'><font color='white'>Name</font></th>
  
      <th bgcolor='green'><font color='white'>View</font></th>
  
      <th bgcolor='green'><font color='white'>Approve</font></th>
  
      </tr>
 
     
<?php

$i = 0;

 

$number = 0;

while($row = mysql_fetch_array($result)){


$number++;

 

?>

<?php

$i++;

 

if($i%2)

{

$bg_color = "#EEEEEE";

}

else {

$bg_color = "#E0E0E0";

}

?>

  
      <script language='JavaScript'>
 
      checked = false;
  
      function checkedAll () {
  
      if (checked == false){checked = true}else{checked = false}
  
      for (var i = 0; i < document.getElementById('form1').elements.length; i++) {
  
      document.getElementById('form1').elements[i].checked = checked;
 
      }
  
      }
  
      </script>
  
      <tr bgcolor='". $bg_color ."'>
  
      <td><center>
 
      <strong><font color='red'>

  
      </font></strong>

      <input type="checkbox" name="del[]" id="del" value="<?php echo $row['cno']; ?>"></center></td>
 
      <td><center>
 
      <strong><font color='red'><?php echo $row['cno']; ?></font></strong>

      </center></td>
	     <td><center>

      <strong><?php echo $row['date']; ?></strong>

      </center></td>

      <td><center>

      <strong><?php echo $row['checkin']; ?></strong>

      </center></td>

      <td><center>

      <strong><?php echo $row['checkout']; ?></strong>

      </center></td>

      <td><center><?php $result1 = mysql_query("Select * from guest where code='$row[cno]'");
$rows = mysql_fetch_array($result1); ?>
	  <strong><font color='blue'><strong><font color='blue'><?php echo $rows['lname'] .', '. $rows['fname'] ?></font></strong></font></strong>

      
  
      </center></td>
  
      <td><center><strong><a href='edit.php?code=<?php echo $row[cno]; ?>' class="style6">View</a></strong>

      </center></td>
 
      <td><center><Strong><a href='approve.php?id=<?php echo $row['cno']; ?>' class="style6">Approve</a></Strong>
  
      </center></td>
 
      </tr>
  
      <?php } ?>
  
      </table>

i want to show 10 per pages only can anyone help me please?

Member Avatar for diafol

Please search this forum - about 10 such questions have been asked over the last 4 months.

ive already search in google and yahoo but i don't know how to add that code to my code.

here's my code in displaying a data in the table

$result = mysql_query("SELECT * FROM rent where status = 'pending' order by cno asc");
$count = mysql_num_rows($result);

<table border='1' cellspacing='0' width='612'>
   	<tr>
	<th colspan='8' bgcolor="#000000"><font color='#00FF00'>PENDING REQUEST</font></th>
	</tr>
      <tr>
  		 
      <th bgcolor='green'><font color='white'>
   
      <input type='checkbox' name='checkall' onclick='checkedAll();' />
   
      </font></th>
   
      <th bgcolor='green'><font color="white">ID</font></th>
 	<th bgcolor='green'><font color='white'>Book Date</font></th>
      <th bgcolor='green'><font color='white'>Check In</font></th>
 
      <th bgcolor='green'><font color='white'>Check Out</font></th>
  
      <th bgcolor='green'><font color='white'>Name</font></th>
  
      <th bgcolor='green'><font color='white'>View</font></th>
  
      <th bgcolor='green'><font color='white'>Approve</font></th>
  
      </tr>
 
     
<?php

$i = 0;

 

$number = 0;

while($row = mysql_fetch_array($result)){


$number++;

 

?>

<?php

$i++;

 

if($i%2)

{

$bg_color = "#EEEEEE";

}

else {

$bg_color = "#E0E0E0";

}

?>

  
      <script language='JavaScript'>
 
      checked = false;
  
      function checkedAll () {
  
      if (checked == false){checked = true}else{checked = false}
  
      for (var i = 0; i < document.getElementById('form1').elements.length; i++) {
  
      document.getElementById('form1').elements[i].checked = checked;
 
      }
  
      }
  
      </script>
  
      <tr bgcolor='". $bg_color ."'>
  
      <td><center>
 
      <strong><font color='red'>

  
      </font></strong>

      <input type="checkbox" name="del[]" id="del" value="<?php echo $row['cno']; ?>"></center></td>
 
      <td><center>
 
      <strong><font color='red'><?php echo $row['cno']; ?></font></strong>

      </center></td>
	     <td><center>

      <strong><?php echo $row['date']; ?></strong>

      </center></td>

      <td><center>

      <strong><?php echo $row['checkin']; ?></strong>

      </center></td>

      <td><center>

      <strong><?php echo $row['checkout']; ?></strong>

      </center></td>

      <td><center><?php $result1 = mysql_query("Select * from guest where code='$row[cno]'");
$rows = mysql_fetch_array($result1); ?>
	  <strong><font color='blue'><strong><font color='blue'><?php echo $rows['lname'] .', '. $rows['fname'] ?></font></strong></font></strong>

      
  
      </center></td>
  
      <td><center><strong><a href='edit.php?code=<?php echo $row[cno]; ?>' class="style6">View</a></strong>

      </center></td>
 
      <td><center><Strong><a href='approve.php?id=<?php echo $row['cno']; ?>' class="style6">Approve</a></Strong>
  
      </center></td>
 
      </tr>
  
      <?php } ?>
  
      </table>

i want to show 10 per pages only can anyone help me please?

:twisted:

this is my code please ignore some codes here then look to labels only where you can get the pagination you want:


<?php

//connection to database
$error = "Could not connect to database";
mysql_connect('localhost','root','') or exit($error);
mysql_select_db('dbapm') or exit($error);;

//max display per page
$per_page = 3;
//get start variable

if(isset($_GET)){
$start = $_GET; //=0
}
//count records

$record_count = mysql_num_rows(mysql_query("SELECT * FROM tblholder_reg"));


//count max pages
$max_pages = $record_count / $per_page;
//$start = 0;
if(!$start)

$start = 0;


//dispaly data
$get = mysql_query("SELECT * FROM tblholder_reg LIMIT $start, $per_page");
while ($row = mysql_fetch_assoc($get))
{
$id = $row;
$Account_number = $row;
$Account_name = $row;
$Gender = $row;
$Home_number = $row;
$Mobile_number = $row;
$Email_address = $row;
$User_name = $row;
$Security_number = $row;

echo "
<table border='1' width='35%'><tr><td><b><font size='3'>id:</b></td><td><font size='2'>$id</font></td></tr>
<td><b><font size='3'>Account_number:</font></b></td><td><font size='2'>$Account_number</font></td></tr>
<td><b><font size='3'>Account_name:</font></b></td><td><font size='2'>$Account_name</font></td> </tr>

<td><b><font size='3'>Gender:</font></b></td><td><font size='2'>$Gender</font></td></tr>
<td><b><font size='3'>Home number:</font></b></td><td><font size='2'>$Home_number</font></td></tr>
<td><b><font size='3'>Mobile number:</font></b></td><td><font size='2'>$Mobile_number</font></td></tr>
<td><b><font size='3'>Email:</font></b></td><td><font size='2'>$Email_address</font></td></tr>
<td><b><font size='3'>Username:</font></b></td><td><font size='2'>$User_name</font></td></tr>
<td><a href='update.php?'><font size='2'>Update</font></a> - <a href='insert.php?'><font size='2'>Insert</font></a> - <a href='delete.php?'><font size='2'>Delete</font></a></td></tr></table>";

}

//setup prev and next variables

$prev = $start - $per_page;

$next = $start + $per_page;

//show prev
if($start!=0)

echo "<a href='admin1.php?start=$prev'><font face='verdana' size='1'>Previous</font></a>&nbsp;";

//show page numbers
//set var for 1st page

$i=1;
for ($x=0; $x<$record_count;$x=$x + $per_page)
{
if($start!=$x)
echo "<a href='index.php?start=$x'>$i</a>";
else
echo "<a href='index.php?start=$x'><b>$i</b></a>";
$i++;


}

//set variables for 1st page

//show next
if(!($start>=$record_count-$per_page))
echo "&nbsp;<a href='admin1.php?start=$next'><font face='verdana' size='1'>Next</font></a>";

?>

Member Avatar for diafol

You wanna think again about the <font> tags?

thanks for the reply i already solve the problem :) hope you will help me again to my next problem :) god bless.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.