Forums
This topic is locked
pagination - please help me
Posted 15 Nov 2006 12:47:54
1
has voted
15 Nov 2006 12:47:54 sally bierton posted:
Hi i am having a problem with a pagination script. i am getting values from a form that has 3 queries. my pagination works when i have only 1 query. so i dont know why it wont work with all 3.here is my script.
<html xmlns="www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>addpaymentform</title>
</head>
<body
<td width="1" bgcolor="#666FF"></td>
<td width="67%">
<?php
/*program: detailedsearch.php
*search payment details
*/
$dateYEAR= $_POST['dateYEAR'];
$dateMONTH=$_POST['dateMONTH'];
$dateDAY=$_POST['dateDAY'];
$newdate.="$dateYEAR-$dateMONTH-$dateDAY";
?>
<?
$dateYr= $_POST['dateYr'];
$dateMO=$_POST['dateMO'];
$dateDay=$_POST['dateDay'];
$newdate1.="$dateYr-$dateMO-$dateDay";
?>
<?
$method=$_POST['method'];
if ($method=='')
{$method =='';}
?>
<?
$amount=$_POST['amount'];
include ("connection.php"
$limit =2; // results to show per page
$query_count = "SELECT * FROM paymentform where date between '$newdate'AND '$newdate1' ";
$result_count = mysql_query($query_count);
$totalrows = mysql_num_rows($result_count);
$page=$_GET['page'];
if(empty($page)){
$page = 1;
}
// Get all the data from the "detailedsearch" table
if ($method=='')
{
$limitvalue = $page * $limit - ($limit);
$query="SELECT * FROM paymentform WHERE date between '$newdate'AND '$newdate1' ORDER BY date LIMIT $limitvalue, $limit";
$result = mysql_query($query);
$num=mysql_num_rows($result);
if(mysql_num_rows($result) == 0){
echo"Nothing to Display - No More Records!";
}
}
else
{
$limitvalue = $page * $limit - ($limit);
$query="SELECT * FROM paymentform where date between '$newdate' AND '$newdate1' and method='$method' ORDER BY date LIMIT $limitvalue, $limit";
$result = mysql_query($query);
$num=mysql_num_rows($result);
if(mysql_num_rows($result) == 0){
}
}
{
if ($amount=$amount)
$query="SELECT * FROM paymentform where amount='$amount' ORDER BY date LIMIT $limitvalue, $limit";
$result = mysql_query($query);
$num=mysql_num_rows($result);
if(mysql_num_rows($result) == 0){
}
}
echo "<table border='5'>";
echo "<tr> <th>Date</th><th>Method<th>Amount<th>Details<th>Checked<th>Allocated<th>Datefound</th></tr>";
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
// Print out the contents of each row into a table
echo "<tr><td>";
echo $row['date'];
echo "</td><td>";
echo $row['method'];
echo "</td><td>";
echo $row['amount'];
echo "</td><td>";
echo $row['details'];
echo "</td><td>";
echo $row['checked'];
echo "</td><td>";
$id=$row['id'];
?>
<p><a href="allocate.php?id=<?echo$id;?>">allocate</a>
<?
echo "</td><td>";
echo $row['datefound'];
echo "</td></tr>";
}
echo "</table>";
if($page != 1){
$pageprev = $page-1;
echo"<a href=\"$PHP_SELF?page=$pageprev\">PREV ".$limit."</a> ";
}else{
echo"PREV " .$limit." ";
}
$numofpages = $totalrows / $limit;
for($i = 1; $i <= $numofpages; $i++){
if($i == $page){
echo$i." ";
}else{
echo"<a href=\"$PHP_SELF?page=$i\">$i</a> ";
}
}
if(($totalrows % $limit) != 0){
if($i == $page){
echo $i." ";
}else{
echo"<a href=\"$PHP_SELF?page=$i\">$i</a> ";
}
}
if(($totalrows - ($limit * $page)) >=0){
$pagenext = $page+1;
echo" <a href=\"$PHP_self?page=$pagenext\">NEXT ".$limit."</a>";
}else{
echo(" NEXT " .$limit);
}
mysql_free_result($result);
?>
<p><a href="detailedsearch.php">Back To The Form </a></p>
Replies
Replied 16 Nov 2006 04:20:45
16 Nov 2006 04:20:45 LorD ExoskeletoN replied:
hi sally... i just read a forum the same problem with yours...he just change all the $_POST into $_GET and also the method of the FORM of course...and it works...try it..
Good luck..More Power
<div align=right>
afraid NOT to FAIL for you learn NOTHING
www.nasbikesphilippines.bravehost.com
<img src="www.motorcyclephilippines.com/forums/signaturepics/sigpic14460_2.gif" border=0></div id=right>
Good luck..More Power
<div align=right>
afraid NOT to FAIL for you learn NOTHING
www.nasbikesphilippines.bravehost.com
<img src="www.motorcyclephilippines.com/forums/signaturepics/sigpic14460_2.gif" border=0></div id=right>