Hi all,
I am having a problem with a php page im working on.
The page is a results page from a keyword search page.
On this page i limit the records to 10 and have page numbers so the user can click on the page they want records for.
I also have a script at the top of the page that directs the user back to the search form and echos a message if no fields are filled in and the search is submitted.
The problem i have is if i click one of the page numbers to view records on that recordset page, the page doesnt load, instead the header code at the top of my page is executed. and i get redirected to the search form as if i just entered a blank search?
I assume this is due to the way i have my code laid out but i am unsure how to fix the issue while retaining my header script at the top of the page.
Here is my entire page code so you can see what i am reffering to.
<?php require_once('Connections/
EE_con.php
'); ?>
<?php
$keyword_street = "";
$keyword_village = "";
$case = 0;
if(!isset($_REQUEST["keywo
rd_street"
]) || $_REQUEST["keyword_street"
]=='')
{
$keyword_street = "<font color=\"red\">Please enter this field!</font>";
}
if(!isset($_REQUEST["keywo
rd_village
"]) || $_REQUEST["keyword_village
"]=='')
{
$keyword_village = "<font color=\"red\">Please enter this field!</font>";
}
if($keyword_village!="" && $keyword_street!="")
{
header("Location: keyword2.php?street=$keywo
rd_street&
village=$k
eyword_vil
lage");
// Keyword2.php is the name of the page where my search form is.
exit();
}
?>
<?
$maxRows_Recordset1 = 10;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Reco
rdset1']))
{
$pageNum_Recordset1 = $_GET['pageNum_Recordset1'
];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;
mysql_select_db($database_
EE_con, $EE_con);
$keywordstreet = $_REQUEST['keyword_street'
];
$keywordvillage = $_REQUEST['keyword_village
'];
$K_street = $_POST['keyword_street'];
$K_village = $_POST['keyword_village'];
if (strlen($_POST['keyword_st
reet']) > 0) {
$test = "one";
}
if (strlen($_POST['keyword_vi
llage']) > 0) {
$test2 = "two";
}
if ($test = "one" && $test2 = "two") {
$where_clause = "WHERE property_address1 LIKE '%$keywordstreet%' AND property_towncity LIKE '%$keywordvillage%'";
}
$query_Recordset1 = "SELECT * FROM properties $where_clause ORDER BY price ASC";
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_R
ecordset1,
$EE_con) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Records
et1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1
);
if (isset($_GET['totalRows_Re
cordset1']
)) {
$totalRows_Recordset1 = $_GET['totalRows_Recordset
1'];
} else {
$all_Recordset1 = mysql_query($query_Records
et1);
$totalRows_Recordset1 = mysql_num_rows($all_Record
set1);
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1
/$maxRows_
Recordset1
)-1;
if ($totalRows_Recordset1 == 0){
echo "There are no results matching your search criteria <BR> Keyword 1:$K_street <BR> Keyword 2:$K_village <BR><BR> Click Here to search again!";
}
echo "whereclause:$where_clause
<br>";
echo "keyword Street: $keywordstreet<br>";
echo "keyword Village: $keywordvillage<br>";
echo "test: $test<br>";
echo "test2: $test2<br>";
do {
?>
<p><?php echo $row_Recordset1['property_
numname'];
?></p>
<p><?php echo $row_Recordset1['property_
address1']
; ?></p>
<p><?php echo $row_Recordset1['property_
address2']
; ?></p>
<p><?php echo $row_Recordset1['property_
towncity']
; ?></p>
<p><?php echo $row_Recordset1['prop_post
code']; ?></p>
<p><?php echo $row_Recordset1['pic1']; ?></p>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Records
et1)); ?>
Page <?php for ($i = 0; $i <= $totalPages_Recordset1; $i++) {
$href = sprintf('%s?pageNum_Record
set1=%d%s'
, $currentPage, $i, $queryString_Recordset1);
$label = $i + 1;
echo '<a href="'.$href.'">'.$label.
'</a>';
}
?>
<?php
mysql_free_result($Records
et1);
?>
Start Free Trial