• Hi
    I am trying to pass a query string called postcode (your zip code in the states) from one page to another. On the 2nd page I want to use postcode to filter some details of people to identify the person with the relevant postcode.

    My query string for example is –

    /registration/?postcode = 2880

    I know that on the following line of code –
    <strong>where tblcoordinator_id_contact_details.Postcode = postcode");</strong> which is about line 25 on page 2
    if I put in the actual value of the postcode i.e.. ‘2880’ it gives me the correct result.
    if I put in the querystring name of postcode i.e.. ‘postcode’ it gives me every person.
    if I put in the function name of the postcode i.e.. $vars it gives me no results.

    So I am at a real loss simple process. But not wanting to do posts using a page and filtering. I need help desperately. Please..

    So the code that I am using on page 2 or the registration page is –
    (by the way I am using a short codeplugin – Shortcode exec PHP)

    global $wpdb;
    function add_query_vars_filter( $vars ){
      $vars[] = "postcode";
      return $vars;
    }
    add_filter( 'query_vars', 'add_query_vars_filter' );
    $result = $wpdb->get_results( "SELECT tblcoordinator_id_contact_details.ID,
    tblcoordinator_id_contact_details.Firstname,
    tblcoordinator_id_contact_details.LastName,
    tblcoordinator_id_contact_details.Fullname,
    tblcoordinator_id_contact_details.Location,
    tblcoordinator_id_contact_details.Street,
    tblcoordinator_id_contact_details.Postal,
    tblcoordinator_id_contact_details.Town,
    tblcoordinator_id_contact_details.State,
    tblcoordinator_id_contact_details.Postcode,
    tblcoordinator_id_contact_details.Phone1,
    tblcoordinator_id_contact_details.Phone2,
    tblcoordinator_id_contact_details.Fax,
    tblcoordinator_id_contact_details.Email
    FROM tblcoordinator_id_contact_details
    where tblcoordinator_id_contact_details.Postcode = postcode");
    //echo "
    <pre>"; print_r($result); echo "</pre>
    ";
    echo "Firstname"."  "."LastName"."
    
    ";
    foreach($result as $row)
     {
     echo $row->Firstname."  ".$row->LastName."";
     }

    [Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

    Thanks
    Peter

Viewing 1 replies (of 1 total)
  • If the value of the postcode appears in the address line of the browser like this: somedomain.com/maybe-a-post-title/?postcode=54321, then you can get the value like this:

    $postcode = $_GET['postcode'];

    then use $postcode in your query string.

Viewing 1 replies (of 1 total)
  • The topic ‘Pass query String to Page query’ is closed to new replies.