OK, I have no idea what is going wrong here...
I have a cookie that holds the User's ID...
On all of the pages there is a button that is labeled 'Favorites'...
If there is no User ID in the cookie, the link for the button will take you to a page to register the User...
If there is a User ID, the link takes the user to fav_check.php...
I have the code for this page below...
<?
// Get $userID
include ("check_cookie.php");
// Get list of apartments from favorites table that match UserID
// Access DB
include("final_code/dbConnect.php");
// Set up query on favorites table...
$fav_results = mysql_query("SELECT *
FROM favorite
Where UserID = '$userID'");
// Send through loop to pull info from 'apartments'...
if ( $fav_myrow = mysql_fetch_array($fav_results))
{
$totalrows = mysql_num_rows($fav_results);
$i = 0;
do
{
// Set AptID and Rent
$aptid_1 = $fav_myrow["AptID"];
setlocale(LC_MONETARY, 'en_US');
$aptrent = money_format('%#4n',($fav_myrow['Rent']));
// Run $aptid_1 through new query
$apt_result = mysql_query("Select * From apartments Where AptID=$aptid_1");
if ($apt_myrow = mysql_fetch_array($apt_result))
{
include("final_code/match_percent.php");
// Load information from query and $match_percent into array
$output[$i][0] = $match_percent;
$output[$i][1] = $aptid_1;
$output[$i][2] = $apt_myrow['AptAddress'];
$output[$i][3] = $apt_myrow['AptApt'];
$output[$i][4] = $apt_myrow['AptCity'];
$output[$i][5] = $aptrent;
if ( $i < $totalrows )
{
$i = ($i + 1);
}
}
else
{
echo "Sorry Charlie";
}
}
while ( $fav_myrow = mysql_fetch_array($fav_results));
// Sort array desc
rsort($output);
$serial = serialize($output);
// Send array to fav_list.php to display favorite listings
$url = "http://www.bnrestaurants.com/fav_list.php?list=".urlencode($serial)."";
$delay = "0";
echo '<meta http-equiv="refresh" content="'.$delay.';url='.$url.'">';
}
else
{
// Send to Search Form
$url = "http://www.bnrestaurants.com/search.php";
$delay = "0";
echo '<meta http-equiv="refresh" content="'.$delay.';url='.$url.'">';
}
?>
This page checks a table called 'favorite' to see if the User has any favorites to list...
If they do, it loads the listings into an array and sends it to another page to display the listings...
If they don't, it will take them to the search page...
Now here is the problem I'm running into...
When I click the 'Favorites' button, and the user gets sent through the fav_check.php page, any changes I made are not reflected in the display page (fav_list.php)...
Example...
I hit the 'Favorites' button and up pops a list of Apartments that I have saved as favorites...
I select one and get it's detail page...
There is a link that says "Remove from Favorites"...
I hit that and the record in the 'favorite' table is deleted...
I hit the 'Favorites' button again and the record still shows up...
The user automatically gets routed through fav_check.php before they get to fav_list.php, so they should get a fresh array with the new information..
But for some reason it retains the old info...
Now if I call fav_check.php through the address bar instead of the 'Favorites' button, it works fine...
Is this a cache or reload problem...?