rbragg Posted August 3, 2007 Share Posted August 3, 2007 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 https://forums.phpfreaks.com/topic/63185-building-a-url-a-db-query/ Share on other sites More sharing options...
rbragg Posted August 3, 2007 Author Share Posted August 3, 2007 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 https://forums.phpfreaks.com/topic/63185-building-a-url-a-db-query/#findComment-314955 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.