[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.4

problem with PHP limit page and  header("Location:

Asked by satmanuk in PHP Scripting Language

Tags: php, limit, header, location

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["keyword_street"]) || $_REQUEST["keyword_street"]=='')
{
      $keyword_street = "<font color=\"red\">Please enter this field!</font>";
}

if(!isset($_REQUEST["keyword_village"]) || $_REQUEST["keyword_village"]=='')
{
      $keyword_village = "<font color=\"red\">Please enter this field!</font>";
}
     
if($keyword_village!="" && $keyword_street!="")
{
      header("Location: keyword2.php?street=$keyword_street&village=$keyword_village");
      // Keyword2.php is the name of the page where my search form is.
     exit();
}
?>

<?

$maxRows_Recordset1 = 10;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Recordset1'])) {
  $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_street']) > 0) {
$test = "one";
}
if (strlen($_POST['keyword_village']) > 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_Recordset1, $EE_con) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);

if (isset($_GET['totalRows_Recordset1'])) {
  $totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
} else {
  $all_Recordset1 = mysql_query($query_Recordset1);
  $totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
}
$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_postcode']; ?></p>
    <p><?php echo $row_Recordset1['pic1']; ?></p>
    <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>

Page           <?php for ($i = 0; $i <= $totalPages_Recordset1; $i++) {
  $href = sprintf('%s?pageNum_Recordset1=%d%s', $currentPage, $i, $queryString_Recordset1);
  $label = $i + 1;
  echo '<a href="'.$href.'">'.$label.'</a>';
}
?>

<?php
mysql_free_result($Recordset1);
?>
 
Related Solutions
Keywords: problem with PHP limit page and heade…
 
Loading Advertisement...
 
[+][-]11/13/07 04:29 PM, ID: 20276725Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: PHP Scripting Language
Tags: php, limit, header, location
Sign Up Now!
Solution Provided By: steelseth12
Participating Experts: 10
Solution Grade: A
 
[+][-]11/13/07 03:19 PM, ID: 20276265Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/13/07 03:29 PM, ID: 20276345Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/13/07 03:35 PM, ID: 20276387Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/13/07 03:38 PM, ID: 20276412Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/13/07 03:51 PM, ID: 20276531Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/13/07 04:00 PM, ID: 20276597Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/13/07 04:04 PM, ID: 20276624Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/13/07 04:06 PM, ID: 20276641Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/13/07 04:18 PM, ID: 20276693Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/13/07 05:04 PM, ID: 20276879Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091118-EE-VQP-93 / EE_QW_2_20070628