Jump to content

building a URL & a db query


rbragg

Recommended Posts

I am building a URL and a SELECT query at the same time. I have a GET method form on search.php. It sends the user to searchResults.php where I am retrieving searchStatus:

 

<?php
if ( !empty($_GET['searchStatus']) ) # if searched
{
  $_SESSION['status'] = mysql_real_escape_string($_GET['searchStatus']); # get selected status from previous page
  $searchStatus = $_SESSION['status'];
  $querySearch.= "AND vigil_call.status_num = '$searchStatus' ";
}
if ( !empty($_GET['refreshStatus']) ) # if refreshed, grab session from URL
{
  $refreshStatus = mysql_real_escape_string($_GET['refreshStatus']);
  $querySearch.= "AND vigil_call.status_num = '$refreshStatus' ";
}
?>

 

If the user is sent from the previous page, then the query is built with the searched status. However, this results page is auto refreshed. On the refresh,  I am trying to display the same results ... just updated. So, I am grabbing the session from the newly built URL.

 

<?php
# build URL
$url = "?lastCall=" . $_SESSION['dbLast'] . "&refreshEagle=" . $_SESSION['eagle'] . "&refreshStatus=" . $_SESSION['status'] . 
"&refreshHall=" . $_SESSION['hall']. "&refreshTech=" . $_SESSION['tech'];
?>

 

I am testing by echoing the values of the 2 variables and it correctly echoes a duplicate number:

 

<?php
echo "status: " . $_SESSION['status'];
echo "<br>refresh status: " . $refreshStatus;
?>

 

The query is successful when first reaching the page and I get my results, but upon refresh the I have no results.  :-\ Can someone be of assistance? Or maybe you know of an easier/cleaner method to achieve the same effect?

Link to comment
Share on other sites

Or better yet - why wouldn't this work?

 

<?php
# build URL
$url = "?lastCall=" . $_SESSION['dbLast'] . "&refreshEagle=" . $_SESSION['eagle'] . "&searchStatus=" . $_SESSION['status'] . "&refreshHall=" . $_SESSION['hall']. "&refreshTech=" . $_SESSION['tech'];

if ( !empty($_GET['searchStatus']) )
{
  $_SESSION['status'] = mysql_real_escape_string($_GET['searchStatus']); 
  $searchStatus = $_SESSION['status'];
  $querySearch.= "AND vigil_call.status_num = '$searchStatus' ";
}
?>

 

The session is able to be echoed from the URL but it is still not used in my query. :(

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.