Looking for help as to why these nested loops with queries aren't working
So, I have a nested loop that gets user data
$user="johndoe";
$search1 = "SELECT search, filename, searchloc, searchvar from user_searches where user = '$user'";
$users = mysql_query($search1) or die("User Query failed");
while ($srow = mysql_fetch_row($users)) {
$search = $srow[0];
$filename = $srow[1];
$searchloc = $srow[2]; //(IE city)
$searchvar = $srow[3]; //(IE boston)
include 'search_code.php';
}
Now, inside search_code.php there is a new query that takes that values of searchloc and searchvar and gets a new set of data.
$area_search = "SELECT area, region, state FROM locations where $searchloc = '$searchvar' order by state,area";
$area_results = mysql_query($area_search) or die("Area Query failed");
while ($areas = mysql_fetch_row($area_results)) {
$var1 = $areas[0];
//do some stuff here. Works just fine when not run in the nested loop
}
So, what happens is that the first pass through for johndoe (IE boston) gets the correct behavior, but the second pass through (IE tampa) fails the inner loop "area_search" query. This would be great if I only have 1 user with one search area.
What do I need to do to get that inner query to fire correctly each time just like the first?
Any assistance is always appreciate.