The time now is Sat Oct 11, 2008 11:41 am
All times are GMT
|
|
|
Posted: Mon Aug 07, 2006 5:22 am Post subject:
my_pagina_class
Subject description: php pagination class
|
|
|
My sql sets up a variable number of fields as well as search values. I get the pagination navigation bar on the first screen, but am kicked into a different navigation set on the second screen. My php pagination script that invokes the my_pagina class is below. Please help.
<?php
include ('my_pagina_class.php');
$test = new MyPagina;
if ($_SERVER['REQUEST_METHOD'] == "POST") {
$typ = $_POST['typ'];
$city = $_POST['city'];
$state = $_POST['state'];
$dayB = $_POST['dayB'];
$monthB = $_POST['monthB'];
$yearB = $_POST['yearB'];
$dayE = $_POST['dayE'];
$monthE = $_POST['monthE'];
$yearE = $_POST['yearE'];
$beds = $_POST['beds'];
$range = $_POST['range'];
}
// Generate the SQL command for doing a select from the Database
$searchStmt = "SELECT *
FROM ownerjan,touristjan
WHERE " ;
if ($typ)
$searchStmt .= "ownerjan.typ LIKE '%$typ%' AND ";
if ($city)
$searchStmt .= "ownerjan.city LIKE '%$city%' AND " ;
if ($state)
$searchStmt .= "ownerjan.state LIKE '%$state%' AND " ;
if ($dayB)
$searchStmt .= "touristjan.dayB LIKE '%$dayB%' AND " ;
if ($monthB)
$searchStmt .= "touristjan.monthB LIKE '%$monthB%' AND " ;
if ($yearB)
$searchStmt .= "touristjan.yearB LIKE '%$yearB%' AND " ;
if ($dayE)
$searchStmt .= "touristjan.dayE LIKE '%$dayE%' AND " ;
if ($monthE)
$searchStmt .= "touristjan.monthE LIKE '%$monthE%' AND " ;
if ($yearE)
$searchStmt .= "touristjan.yearE LIKE '%$yearE%' AND " ;
if ($beds)
$searchStmt .= "touristjan.beds LIKE '%$beds%' AND " ;
if ($range)
$searchStmt .= "touristjan.range LIKE '%$range%' AND " ;
$searchStmt .= "ownerjan.username = touristjan.username AND " ;
$stmt= substr($searchStmt, 0, strlen($searchStmt)-4) ;
$test->sql = $stmt; // the (basic) sql statement (use the SQL whatever you like)
$result = $test->get_page_result(); // result set
$num_rows = $test->get_page_num_rows(); // number of records in result set
$nav_links = $test->navigation(" , ", "currentStyle"); // the navigation links (define a CSS class selector for the current link)
$nav_info = $test->page_info("to"); // information about the number of records on page ("to" is the text between the number)
$simple_nav_links = $test->back_forward_link(true); // the navigation with only the back and forward links, use true to use images
$total_recs = $test->get_total_rows(); // the total number of records
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Stand By Oz Accomodation Search</title>
<link rel='stylesheet' type='text/css' href='style.css'>
</head>
<body>
<p><?php echo "record ".$nav_info."".$total_recs; ?></p>
<?php
for ($i = 0; $i < $num_rows; $i++) {
$name = mysql_result($result, $i, "name");
$addr = mysql_result($result, $i, "addr");
$city = mysql_result($result, $i, "city");
$state = mysql_result($result, $i, "state");
$email = mysql_result($result, $i, "email");
$url = mysql_result($result, $i, "url");
$phone = mysql_result($result, $i, "phone");
$beds = mysql_result($result, $i, "beds");
$reg_price= mysql_result($result, $i, "reg_price");
$price = mysql_result($result, $i, "price");
$dayB = mysql_result($result, $i, "dayB");
$monthB = mysql_result($result, $i, "monthB");
$yearB = mysql_result($result, $i, "yearB");
$dayE = mysql_result($result, $i, "dayE");
$monthE = mysql_result($result, $i, "monthE");
$yearE = mysql_result($result, $i, "yearE");
echo "<center><table class='tourist'>";
echo "<tr><td>Name: ".$name. "</td></tr>";
echo "<tr><td>Address: ".$addr. "</td></tr>";
echo "<tr><td>City: ".$city. "</td>";
echo "<td>State: ".$state. "</td></tr>";
echo "<tr><td>Email: ".$email. "</td></tr>";
echo "<tr><td>URL: ".$url. "</td></tr>";
echo "<tr><td>Phone: ".$phone. "</td></tr>";
echo "<tr><td>Beds: ".$beds. "</td></tr>";
echo "<tr><td>Regular Price: $".$reg_price."</td><td>Standby Price: $".$price."</td></tr>";
echo "<tr><td>Available from: ".$dayB." ".$monthB." ".$yearB." to ".$dayE." ".$monthE." ".$yearE."</table></center><br>\n";
}
echo "<p>".$nav_links."</p>";
?>
</body>
</html>
<?php $test->free_page_result(); // if your result set is large then free the result here ?>
|
|
| Back to top |
|
 |
fourcs
Joined: 07 Aug 2006 Posts: 2 Location: australia
|
Posted: Mon Aug 07, 2006 8:26 am Post subject:
my_pagina_class
Subject description: pagination
|
|
|
The pagination navigation bar when clicked bumps me into a read-out of the entire database, not my query.
|
|
| Back to top |
|
 |
fourcs
Joined: 07 Aug 2006 Posts: 2 Location: australia
|
Posted: Tue Aug 08, 2006 10:06 am Post subject:
my_pagina_class
Subject description: fix
|
|
|
I fixed it. The class was apparently looking for the _GET array; my form used the post method. The fix was to change this to get as well as referencing the fields with the _GET array. The my_pagina class works quite well!
|
|
| Back to top |
|
 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
| Link to this Page |
|
If you want to link to this page you can use the following URL:
Example:
|
|
| The PHP Web-Ring Community
Sign-up to receive daily news on PHP by email.
|
|