Looktrne Posted February 21, 2009 Share Posted February 21, 2009 I have a dating site.. when I use the search page it works fine. for example if I click male seeking female in the quicksearch it displays females... if I then click female seeking male it will still display females but if I submit the search a second time female seeking male it will then return the proper results... what would cause this to only get updated on the second submission of the search form? I don't even know where to start? any help is greatly appreciated you can see the problem at: http://abmatch.com login user:test password:test use the quicksearch just click male seeking female then search then click female seeking male click search (this will show the invalid results from the previous submmission ) click female seeking mail click search again and all is good. any clues? thanks Paul ps.. I am attaching the full code of the search page. this handles the quicksearch and the advanced search they both exhibit the same bug were it takes a second submition to work properly.. the initial search is always fine.. <? switch($search_sort_by) { case "Member Age": $sql_sort_by = " ORDER BY m.age ".($search_sort_by_ad == "Ascending" ? "ASC" : "DESC"); break; case "Member Name": $sql_sort_by = " ORDER BY m.login ".($search_sort_by_ad == "Ascending" ? "ASC" : "DESC"); break; case "Member Country": $sql_sort_by = " ORDER BY p.country ".($search_sort_by_ad == "Ascending" ? "ASC" : "DESC"); break; case "Registration Date": $sql_sort_by = " ORDER BY p.id ".($search_sort_by_ad == "Ascending" ? "ASC" : "DESC"); break; case "Paid Members": $sql_sort_by = " ORDER BY m.unlimited ".($search_sort_by_ad == "Ascending" ? "ASC" : "DESC"); break; } if($action == process_search) { // Collecting search tokens & search tables $sql_from = "dt_profile AS p, dt_members AS m"; $sql_where = ""; $sql_vars = "*, p.name, p.gender, p.country, m.age"; if ($_SERVER['REQUEST_METHOD'] == "POST" || $_SERVER['REQUEST_METHOD'] == "post") { foreach($_SESSION as $k => $v) { if(substr($k, 0, 7) != "search_") continue; $_SESSION[$k] = ""; } } switch($search_type) { case member_code: $sID = $search_member_code; $sID = preg_replace("/[a-z]+/i",'', $sID); if(isset($_SESSION['search_query_save'])&&$_SESSION['search_query_save']!="") { $search_query = $_SESSION['search_query_save']; } else { $sql_where = "p.member_id='$sID' and p.member_id = m.id"; $search_query = "SELECT $sql_vars, p.id, p.country FROM $sql_from WHERE p.status='1' ".($sql_where == "" ? "" : " AND $sql_where")." $sql_sort_by"; $_SESSION['search_query_save'] = $search_query; } break; case easy: case quick_search: foreach($_POST as $k => $v) { if(substr($k, 0, 7) != "search_") continue; $_SESSION[$k] = $v; } $nWas = 0; if($search_gender != "") { if ($search_looking_for != "") { $sql_where = "p.looking_for='$search_gender' AND p.gender='$search_looking_for' "; } else { $sql_where = "p.looking_for='$search_gender' "; } $nWas = 1; } if($search_age_from != "") { $sql_where .= ($nWas ? "AND " : "")."m.age>='$search_age_from' "; $nWas = 1; } if($search_age_to != "") { $sql_where .= ($nWas ? "AND " : "")."m.age<='$search_age_to' "; $nWas = 1; } if($search_city != "") { $sql_where .= ($nWas ? "AND " : "")."p.city LIKE '%$search_city%' "; $nWas = 1; } if($search_state != "") { $sql_where .= ($nWas ? "AND " : "")."p.state LIKE '%$search_state%' "; $nWas = 1; } if($search_country != "") { $sql_where .= ($nWas ? "AND " : "")."p.country LIKE '%$search_country%' "; } if($search_radius != "" && $search_zipcode != "") { $search_zipcode = substr(trim($search_zipcode), 0, 5); $zip_lookup_query = "SELECT longw, latn FROM dt_zips WHERE zipcode = '$search_zipcode' "; $longlatn = q($zip_lookup_query); $longlatn = f($longlatn); if ($longlatn["longw"] != "") { $longitude = $longlatn['longw']; $latitude = $longlatn['latn']; } else { $longitude = 0; $latitude = 180; } $sql_where .= ($nWas ? "and " : "") . " SQRT(POWER(p.longitude - $longitude, 2) + POWER(p.latitude - $latitude, 2))*69 < $search_radius "; $nWas = 1; } if ($search_piconly != "") { $sql_where .= ($nWas ? "AND " : "")." f.member_id = p.member_id AND f.filename_1 <> '' AND p.member_id = m.id "; $nWas = 1; $sql_from = "dt_profile AS p, dt_photos AS f, dt_members AS m "; } else { $sql_where .= ($nWas ? "AND " : "")." p.member_id = m.id "; $nWas = 1; $sql_from = "dt_profile AS p, dt_members AS m "; } // querry runs here $query = "SELECT count(p.id) AS count1 FROM $sql_from WHERE (p.status='1' ".($sql_where == "" ? ")" : " AND $sql_where)"); $rec_count = f(q($query)); $rec_count = $rec_count["count1"]; // } $page_count = 0; if($records_per_page >= $rec_count) { if(isset($_SESSION['search_query_save'])&&$_SESSION['search_query_save']!="") $search_query = $_SESSION['search_query_save']; else $search_query = "SELECT $sql_vars, p.id, p.country FROM $sql_from WHERE p.status='1' ".($sql_where == "" ? "" : " AND $sql_where")." $sql_sort_by"; $_SESSION['search_query_save'] = $search_query; } else { if(isset($_SESSION['search_query_save'])&&$_SESSION['search_query_save']!="") { //$page_count = $rec_count / $records_per_page; //$page_count = ceil($page_count); $page_count = $_SESSION['search_query_result_count']; settype($page_num, "integer"); if(!$page_num){$page_num++;} if($page_num > $page_count) { $page_num = $page_count; } $search_query = $_SESSION['search_query_save']; } else { $page_count = $rec_count / $records_per_page; $page_count = ceil($page_count); $_SESSION['search_query_result_count'] = $page_count; settype($page_num, "integer"); if(!$page_num){$page_num++;} if($page_num > $page_count) { $page_num = $page_count; } $search_query = "SELECT $sql_vars, p.id FROM $sql_from WHERE p.status='1' ".($sql_where == "" ? "" : " AND $sql_where")." $sql_sort_by"; } $from = ($page_num - 1) * $records_per_page; $_SESSION['search_query_save'] = $search_query; $search_query .= " LIMIT $from, $records_per_page"; } break; // case profile_name: $sql_where = "m.login LIKE '%$profile_name%' AND p.member_id = m.id"; $query = "SELECT count(p.id) AS count1 FROM $sql_from WHERE p.status='1' ".($sql_where == "" ? "" : " AND $sql_where")." $sql_sort_by"; $rec_count = f(q($query)); $rec_count = $rec_count["count1"]; $page_count = 0; if($records_per_page >= $rec_count) { if(isset($_SESSION['search_query_save'])&&$_SESSION['search_query_save']!="") $search_query = $_SESSION['search_query_save']; else $search_query = "SELECT $sql_vars, p.id FROM $sql_from WHERE p.status='1' ".($sql_where == "" ? "" : " AND $sql_where")." $sql_sort_by"; $_SESSION['search_query_save'] = $search_query; } else { if(isset($_SESSION['search_query_save'])&&$_SESSION['search_query_save']!="") { $page_count = $_SESSION['search_query_result_count']; settype($page_num, "integer"); if(!$page_num){$page_num++;} if($page_num > $page_count) { $page_num = $page_count; } $search_query = $_SESSION['search_query_save']; } else { $page_count = $rec_count / $records_per_page; $page_count = ceil($page_count); $_SESSION['search_query_result_count'] = $page_count; settype($page_num, "integer"); if(!$page_num){$page_num++;} if($page_num > $page_count) { $page_num = $page_count; } $sql_where = "m.login LIKE '%$profile_name%' AND p.member_id = m.id"; $search_query = "SELECT $sql_vars, p.id FROM $sql_from WHERE p.status='1' ".($sql_where == "" ? "" : " AND $sql_where")." $sql_sort_by"; } $from = ($page_num - 1) * $records_per_page; $_SESSION['search_query_save'] = $search_query; $search_query .= " LIMIT $from, $records_per_page"; } break; // added default: foreach($_POST as $k => $v) { //echo $k."|".$v."<br>"; if(substr($k, 0, 7) != "search_") continue; $_SESSION[$k] = $v; } $nWas = 0; if($search_gender != "") { if ($search_looking_for != "") { $sql_where = "p.looking_for='$search_gender' AND p.gender='$search_looking_for' "; } else { $sql_where = "p.looking_for='$search_gender' "; } $nWas = 1; } if($search_age_from != "") { $year = date("Y") - $search_age_from; $sql_where .= ($nWas ? "AND " : "")."m.age>='$search_age_from' "; $nWas = 1; } if($search_age_to != "") { $year = date("Y") - $search_age_to; $sql_where .= ($nWas ? "AND " : "")."m.age<='$search_age_to' "; $nWas = 1; } if($search_city != "") { $sql_where .= ($nWas ? "AND " : "")."p.city LIKE '%$search_city%' "; $nWas = 1; } if($search_state != "") { $sql_where .= ($nWas ? "AND " : "")."p.state LIKE '%$search_state%' "; $nWas = 1; } if($search_radius != "" && $search_zipcode != "") { $search_zipcode = substr(trim($search_zipcode), 0, 5); $zip_lookup_query = "SELECT longw, latn FROM dt_zips WHERE zipcode = '$search_zipcode' "; $longlatn = q($zip_lookup_query); $longlatn = f($longlatn); if ($longlatn["longw"] != "") { $longitude = $longlatn['longw']; $latitude = $longlatn['latn']; } else { $longitude = 0; $latitude = 180; } $sql_where .= ($nWas ? "AND " : "") . " SQRT(POWER(p.longitude - $longitude, 2) + POWER(p.latitude - $latitude, 2))*69 < $search_radius "; $nWas = 1; } if ($search_piconly != "") { $sql_where .= ($nWas ? "AND " : "")."f.member_id = p.member_id AND p.member_id = m.id AND f.filename_1 <> ''"; $nWas = 1; $sql_from = "dt_profile AS p, dt_members AS m, dt_photos AS f"; } else { $sql_where .= ($nWas ? "AND " : "")."p.member_id = m.id "; $nWas = 1; $sql_from = "dt_profile AS p, dt_members AS m"; } $fields_list = array( // "name of control in html form" => "database field" "search_country" => "country", "search_race" => "race", "search_marital_status" => "marital_status", "search_religion" => "religion", "search_drinking" => "drinking", "search_smoking" => "smoking", "search_food" => "food", "search_occupation" => "occupation", "search_education" => "education", "search_birth_month" => "birth_month", "search_eye_color" => "eye_color", "search_hair_color" => "hair_color", "search_body_type" => "body_type", "search_height" => "height" ); while(list($control, $field) = each($fields_list)) { if(gettype($$control) == "array") { $cntr = $$control; $in_c = ""; for($i = 0; $i < count($cntr); $i++) { $in_c .= "'".$cntr[$i]."', "; } if($in_c != "") { $in_c = substr($in_c, 0, -2); $sql_where .= ($nWas ? "AND " : "")."p.$field IN ($in_c) "; } } else { if($$control != "") { $sql_where .= ($nWas ? "AND " : "")."p.$field = '".$$control."' "; $nWas = 1; } } } if(isset($search_languages)&&(count($search_languages) > 0)) { $in_c = ""; for($i = 0; $i < count($search_languages); $i++) { $in_c .= "'".$search_languages[$i]."', "; } if($in_c != "") { $in_c = substr($in_c, 0, -2); $sql_where .= ($nWas ? "AND " : "")."((p.lang_1 IN ($in_c)) OR (p.lang_2 in ($in_c)) OR (p.lang_3 in ($in_c))) "; $nWas = 1; } } if(isset($search_interests)&&(count($search_interests) > 0)) { $in_c = ""; for($i = 0; $i < count($search_interests); $i++) { $in_c .= "'".$search_interests[$i]."', "; } if($in_c != "") { $in_c = substr($in_c, 0, -2); $query = "SELECT profile_id FROM dt_interests_x WHERE interest_id in ($in_c)"; $rst = q($query); $int_in_c = "0, "; while($row = f($rst)) { $int_in_c .= $row["profile_id"].", "; } $int_in_c = substr($int_in_c, 0, -2); $sql_where .= ($nWas ? "AND " : "")."p.id IN ($int_in_c) "; $nWas = 1; } } // Creating search query: $query = "SELECT count(p.id) AS count1 FROM $sql_from WHERE p.status='1' ".($sql_where == "" ? "" : " AND $sql_where"); $rec_count = f(q($query)); $rec_count = $rec_count["count1"]; $page_count = 0; if($records_per_page >= $rec_count) { if(isset($_SESSION['search_query_save'])&&$_SESSION['search_query_save']!="") $search_query = $_SESSION['search_query_save']; else $search_query = "SELECT $sql_vars, p.id FROM $sql_from WHERE p.status='1' ".($sql_where == "" ? "" : " AND $sql_where")." $sql_sort_by"; $_SESSION['search_query_save'] = $search_query; } else { if(isset($_SESSION['search_query_save'])&&$_SESSION['search_query_save']!="") { //$page_count = $rec_count / $records_per_page; //$page_count = ceil($page_count); $page_count = $_SESSION['search_query_result_count']; settype($page_num, "integer"); if(!$page_num){$page_num++;} if($page_num > $page_count) { $page_num = $page_count; } $search_query = $_SESSION['search_query_save']; } else { $page_count = $rec_count / $records_per_page; $page_count = ceil($page_count); $_SESSION['search_query_result_count'] = $page_count; settype($page_num, "integer"); if(!$page_num)$page_num++; if($page_num > $page_count) { $page_num = $page_count; } $from = ($page_num - 1) * $records_per_page; $search_query = "SELECT $sql_vars, p.id FROM $sql_from WHERE p.status='1' ".($sql_where == "" ? "" : " AND $sql_where")." $sql_sort_by"; } $_SESSION['search_query_save'] = $search_query; $search_query .= " LIMIT $from, $records_per_page"; } } $profiles = q($search_query); // echo $search_query; $search_query_count = "SELECT count(p.id) AS count1 FROM $sql_from WHERE p.status='1' ".($sql_where == "" ? "" : " AND $sql_where"); $search_query_full = "SELECT $sql_vars, p.id FROM $sql_from WHERE p.status='1' ".($sql_where == "" ? "" : " AND $sql_where")." $sql_sort_by"; session_start(); $_SESSION[search_query_count] = $search_query_count; $_SESSION[search_query_full] = $search_query_full; //$_SESSION[search_page_num] = $page_num; //include "templates/search_results.ihtml"; $include_file = "templates/search_results.html"; } else if($action == save_search) { $f = f(q("SELECT id FROM dt_saved_searches WHERE search_name='$search_name' AND member_id='$fMember[id]'")); if($f[id] != "") { $message = "This search name already exists. Please enter a new search name.<br>\n"; } else { $t = time(); $search_query_full = ereg_replace("'", "\\'", $_SESSION[search_query_full]); $search_query_count = ereg_replace("'", "\\'", $_SESSION[search_query_count]); q("INSERT INTO dt_saved_searches (member_id, search_name, search_query_full, search_query_count, timestamp) VALUES('$fMember[id]', '$search_name', '$search_query_full', '$search_query_count', '$t')"); $message = "Search saved successfully.<br>\n"; } $search_query_count = stripslashes($_SESSION[search_query_count]); $search_query_full = stripslashes($_SESSION[search_query_full]); //$page_num = $_SESSION[search_page_num]; $rec_count = f(q($search_query_count)); $rec_count = $rec_count[count1]; $page_count = 0; if($records_per_page >= $rec_count) { if(isset($_SESSION['search_query_save'])&&$_SESSION['search_query_save']!="") $search_query = $_SESSION['search_query_save']; else $search_query = $search_query_full; $_SESSION['search_query_save'] = $search_query; } else { if(isset($_SESSION['search_query_save'])&&$_SESSION['search_query_save']!="") { //$page_count = $rec_count / $records_per_page; //$page_count = ceil($page_count); $page_count = $_SESSION['search_query_result_count']; settype($page_num, "integer"); if(!$page_num){$page_num++;} if($page_num > $page_count) { $page_num = $page_count; } $search_query = $_SESSION['search_query_save']; } else { $page_count = $rec_count / $records_per_page; $page_count = ceil($page_count); $_SESSION['search_query_result_count'] = $page_count; settype($page_num, "integer"); if(!$page_num)$page_num++; if($page_num > $page_count) { $page_num = $page_count; } } $_SESSION['search_query_save'] = $search_query_full; $from = ($page_num - 1) * $records_per_page; $search_query .= " LIMIT $from, $records_per_page"; } $profiles = q($search_query); $include_file = "templates/search_results.html"; } else if($mode == gallery || $mode == detail) { $search_query_count = $_SESSION[search_query_count]; $search_query_full = $_SESSION[search_query_full]; //$page_num = $_SESSION[search_page_num]; $rec_count = f(q($search_query_count)); $rec_count = $rec_count[count1]; $page_count = 0; if($records_per_page >= $rec_count) { if(isset($_SESSION['search_query_save'])&&$_SESSION['search_query_save']!="") $search_query = $_SESSION['search_query_save']; else $search_query = $search_query_full; $_SESSION['search_query_save'] = $search_query; } else { if(isset($_SESSION['search_query_save'])&&$_SESSION['search_query_save']!="") { //$page_count = $rec_count / $records_per_page; //$page_count = ceil($page_count); $page_count = $_SESSION['search_query_result_count']; settype($page_num, "integer"); if(!$page_num){$page_num++;} if($page_num > $page_count) { $page_num = $page_count; } $search_query = $_SESSION['search_query_save']; } else { $page_count = $rec_count / $records_per_page; $page_count = ceil($page_count); $_SESSION['search_query_result_count'] = $page_count; settype($page_num, "integer"); if(!$page_num)$page_num++; if($page_num > $page_count) { $page_num = $page_count; } } $_SESSION['search_query_save'] = $search_query; $from = ($page_num - 1) * $records_per_page; $search_query .=" LIMIT $from, $records_per_page"; } $profiles = q($search_query); $include_file = "templates/search_results.html"; } else if($mode == saved_search) { $f = f(q("SELECT * FROM dt_saved_searches WHERE id='$id' AND member_id='$fMember[id]'")); $serach_query_count = stripslashes($f[search_query_count]); $search_query_full = stripslashes($f[search_query_full]); $message = $f[search_name]; //$page_num = $_SESSION[search_page_num]; $rec_count = f(q($serach_query_count)); $rec_count = $rec_count["count1"]; $page_count = 0; if($records_per_page >= $rec_count) { if(isset($_SESSION['search_query_save'])&&$_SESSION['search_query_save']!="") $search_query = $_SESSION['search_query_save']; else $search_query = $search_query_full; $_SESSION['search_query_save'] = $search_query; } else { if(isset($_SESSION['search_query_save'])&&$_SESSION['search_query_save']!="") { //$page_count = $rec_count / $records_per_page; //$page_count = ceil($page_count); $page_count = $_SESSION['search_query_result_count']; settype($page_num, "integer"); if(!$page_num){$page_num++;} if($page_num > $page_count) { $page_num = $page_count; } $search_query = $_SESSION['search_query_save']; } else { $page_count = $rec_count / $records_per_page; $page_count = ceil($page_count); $_SESSION['search_query_result_count'] = $page_count; settype($page_num, "integer"); if(!$page_num)$page_num++; if($page_num > $page_count) { $page_num = $page_count; } } $_SESSION['search_query_save'] = $search_query; $from = ($page_num - 1) * $records_per_page; $search_query .= " LIMIT $from, $records_per_page"; } $profiles = q($search_query); $_SESSION[search_query_count] = $search_query_count; $_SESSION[search_query_full] = $search_query_full; //$_SESSION[search_page_num] = $page_num; $include_file = "templates/search_results.html"; } else { foreach($_SESSION as $k => $v) { if(substr($k, 0, 7) != "search_") continue; session_unregister($_SESSION[$k]); } //session_unset(); //session_destroy(); $include_file = "engine/pages/easy_search.php"; } if(! e($profiles)) { if($mode != "gallery") { $new_mode = "gallery"; $search_results_header_image = "images/en/gallery_mode.gif" . '" width="136" height="20" border="0'; } else { $new_mode = "detail"; $search_results_header_image = "images/en/detailed_mode.gif" . '" width="143" height="20" border="0'; } if ($fMember[id]) { $save_search_content = ''; if($mode != saved_search && $id == "") { $save_search_content = parseVariables("templates/search_results_save_search_form_content.html",0); } } $change_mode_link = '<a href="index.php?page=search&mode='.$new_mode.'"><img src="'.$search_results_header_image.'"></a>'; $save_search_form = parseVariables("templates/search_results_save_search_form.html",0); } $npages = $page_count; $p = $page_num; if ($npages > 1) { $params = ""; $pages = ""; foreach($_GET as $k => $v) { if($k == "page_num") continue; $params .= "$k=$v&"; } $pages .= "Result Page:"; if ($p != 1) $pages .= '<a href="index.php?'.$params.'page_num='.($p-1).'"><b>'."Previous".'</b></a> '; $lend = floor($p/10)*10; if ($lend < 1) $lend = 1; if ($npages > 19) { $hend = $lend + 19; if ($hend > $npages) $hend = $npages; } else $hend = $npages; for ($i = $lend; $i <= $hend; $i++) { if ($i == $p) $pages .= $i." "; else $pages .= '<a href="index.php?'.$params.'page_num='.$i.'">'.$i.'</a> '; } if ($p != $npages) $pages .= ' <a href="index.php?'.$params.'page_num='.($p+1).'"><b>'."Next".'</b></a> '; } $search_results_pages = ""; if($pages) { $search_results_pages = parseVariables("templates/search_results_pages.html",0); } $search_results_content = ""; if(e($profiles)) { $search_results_content = parseVariables("templates/search_results_no_profiles.html",0); } else { //Set if the viewing user can send/receive IMs if($fMember["unlimited"]==1 && $fMember["unlimited"] > time()) $i_can_im = 1; else $i_can_im = 0; while($profile = f($profiles)) { $age = $profile["age"]; $member_code = sysGetProfileCode($profile[ id ]); $profile[ marital_status ] = f(q("SELECT name FROM dt_marital_status WHERE id='$profile[marital_status]'")); $profile[ marital_status ] = $profile[ marital_status ][ name ]; $profile[ country ] = f(q("SELECT name FROM dt_countries WHERE id='$profile[country]'")); $profile[ country ] = $profile[ country ][ name ]; $profile[ general_info ] = substr($profile[ general_info ], 0, 250).(strlen($profile[ general_info ]) > 250 ? "..." : ""); if($censor_on) { $qWords = q("SELECT name FROM dt_badwords"); while($fWords = f($qWords)) { $replace = ""; for($i = 0; $i < strlen($fWords[name]); $i++) $replace .= "*"; $profile[general_info] = eregi_replace($fWords[name], $replace, $profile[general_info]); } } $f = f(q("SELECT login, reg_date FROM dt_members WHERE id='$profile[member_id]'")); $member_name = $f[login]; $reg_date = $f[reg_date]; if($reg_date > time() - ($new_timelimit*24*60*60)) $new_icon = '<img src="'."images/en/new.gif".'">'; else $new_icon = ""; $fUsersOn = f(q("SELECT id FROM dt_usersonline WHERE userid = '$profile[member_id]'")); if ($fUsersOn["id"] != "") { $online_status = "<b><font color=red>"."Online Now!"."</font></b>";} else if (time() - $profile["lastlogin"] > 0) { if (time() - $profile["lastlogin"] < 3600) { $online_status = "Within 1 Hour";} else if (time() - $profile["lastlogin"] < 7200) { $online_status = "Within 2 Hours";} else if (time() - $profile["lastlogin"] < 10800) { $online_status = "Within 3 Hours";} else if (time() - $profile["lastlogin"] < 86400) { $online_status = "Within 24 Hours";} else if (time() - $profile["lastlogin"] < 172800) { $online_status = "Within 2 Days";} else if (time() - $profile["lastlogin"] < 259200) { $online_status = "Within 3 Days";} else if (time() - $profile["lastlogin"] < 345600) { $online_status = "Within 4 Days";} else if (time() - $profile["lastlogin"] < 432000) { $online_status = "Within 5 Days";} else if (time() - $profile["lastlogin"] < 518400) { $online_status = "Within 6 Days";} else if (time() - $profile["lastlogin"] < 604800) { $online_status = "Within 1 Week";} else { $online_status = "";} } else { $online_status = "More Than 1 Week";} $pr = f(q("SELECT * FROM dt_privacy WHERE member_id='$profile[member_id]'")); $fOnline = f(q("SELECT id, userid FROM dt_usersonline WHERE userid=$profile[member_id]")); //Set if this user returned in the result can send/receive IMs // check if donating member $checkdonate=f(q("SELECT unlimited FROM dt_members WHERE id='$profile[member_id]'")); if ($checkdonate[unlimited]>0) $dm="<img src=\"images/sheart.gif\"><font color=blue>Big Heart</font>"; else $dm=""; // End Donating membercheck PM 7-20-2007 $thisMember = $profile["member_id"]; $fMemberInfo = f(q("SELECT unlimited, unlimited_end FROM dt_members WHERE id='$thisMember'")); if( $fMemberInfo["unlimited"]==1 && ($fMemberInfo["unlimited_end"]>time()) ) $can_be_imed = 1; else $can_be_imed = 0; if($mode != gallery) { $profile_id = $profile[ id ]; $profile_name = $profile[ name ]; $profile_gender = convertGender($profile[gender]); $profile_marital_status = $profile[marital_status]; $profile_city = $profile[city]; $profile_state = $profile[state]; $profile_country = $profile[country]; $general_info = wordwrap($profile[ general_info ],65, "<br>\n", 1); if ($piconly == "") { $fPhoto = f(q("SELECT filename_1 FROM dt_photos WHERE member_id='$profile[member_id]'")); $fPhoto = $fPhoto[filename_1]; } else $fPhoto = $profile[filename_1]; if($fPhoto != ""){ $profile_image = sysGetThumbnail("photos/$fPhoto"); } else { $profile_image = '<img src="images/default_photo.gif" border="0" width="100" height="100">'; } //Check to see if IM is allowed, The person viewing the search results and this particular search result must both be able to IM or IM for nonpaying //members must be turned on for this to be true. Also checks this search result's privacy settings, IMs must not be blocked for IMs to be allowed if (($fOnline[id] != "" && $pr[iM_yn] != 'Y' && $sAuth != $fOnline[userid] && (($can_be_imed==1 && $i_can_im==1)|| $free_im == "on"))) { $profile_im = '<a href="javascript:var newim = window.open(\'im.php?action=message&rid='.$fOnline[userid].'\', \''.$fOnline[userid].'\', \'scrollbars=yes,menubar=no,resizable=0,location=no,screenX=50,screenY=100,width=423,height=550\')" class="e">'; $profile_im .= '<img src="images/im_small.gif" alt="Instant Message" border="0">'."instant message".'</a>'; } else { $profile_im = '<img src="images/im_small_gray.gif" alt="Instant Message Unavailable" border="0">'."instant message"; } $search_results_content .= parseVariables("templates/search_results_detail_mode.html",0); } else { $profile_id = $profile[ id ]; $profile_name = substr($profile[name], 0, 20); $profile_name .= ((strlen($profile[name]) > 20) ? "..." : ""); if($no_of_column == 0) { $search_results_content .= "<table>\n<tr>\n"; } if ($piconly == "") { $fPhoto = f(q("SELECT filename_1 FROM dt_photos WHERE member_id='$profile[member_id]'")); $fPhoto = $fPhoto[filename_1]; } else { $fPhoto = $profile[filename_1]; } if($fPhoto != "") { $profile_image = '<a href="index.php?page=view_profile&id='.$profile[ id ].'">'.sysGetThumbnail("photos/".$fPhoto).'</a>'; //$search_results_content .= '<a href="index.php?page=view_profile&id='.$profile[ id ].'">'.sysGetThumbnail("photos/".$fPhoto).'</a>'; } else { $profile_image = '<a href="index.php?page=view_profile&id='.$profile[ id ].'"><img src="images/default_photo.gif" border="0" width="100" height="100"></a>'; } $search_results_content .= parseVariables("templates/search_results_gallery_mode.html",0); $no_of_column++; if($no_of_column == 3) { $no_of_column = 0; $search_results_content .= "</tr>\n</table>\n"; } } } if($no_of_column > 0) { $search_results_content .= "</tr>\n</table>\n"; } } if($pages) { $search_results_footer = parseVariables("templates/search_results_pages.html",0); } if($include_file == "engine/pages/easy_search.php") { include($include_file); parseVariables("templates/easy_search.html"); } else { parseVariables($include_file); } ?> Link to comment https://forums.phpfreaks.com/topic/146203-php-search-on-my-site-is-acting-strange/ Share on other sites More sharing options...
Looktrne Posted February 21, 2009 Author Share Posted February 21, 2009 also after a search it does not remember what fields you just chose.. I would like it to store the fields you selected so when the search form reloads it is populated with the previous selections.. just give me an example of how to do this with one field and I will figure out the rest.. thanks for any assistance on this here is what the quicksearch html form looks like... I am also adding the advance search form after that quick search form <table border="0" cellpadding="2" cellspacing="0" width="230" align="center"> <form action="index.php?page=search&search_type=quick_search&action=process_search" method=post> <tr> <td colspan="2" style="padding-top:10px;"><div class="headline_w">Quick Search</div></td> </tr> <tr> <td width="100" class="w">I am a</td> <td width="130">{QUICK_SEARCH_GENDER}</td> </tr> <tr> <td class="w">seeking a</td> <td>{QUICK_SEARCH_LOOKING_FOR}</td> </tr> <tr> <td class="w">between ages</td> <td>{QUICK_SEARCH_AGE_FROM}</td> </tr> <tr> <td class="w">and</td> <td>{QUICK_SEARCH_AGE_TO}</td> </tr> <tr> <td class="w">Located within</td> <td> <select name="search_radius"> <option value="5">5 miles of</option> <option value="10">10 miles of</option> <option value="25">25 miles of</option> <option value="50">50 miles of</option> <option value="100">100 miles of</option> <option value="250">250 miles of</option> <option value="500">500 miles of</option> <option value="50000" selected>500+ miles of</option> </select> </td> </tr> <tr> <td class="w">Zip/Postal Code</td> <td> <input type="Text" name="search_zipcode" size="15"> </td> </tr> <tr> <td class="w">Photos only</td> <td><input type="Checkbox" name="search_piconly"></td> </tr> <tr> <td> </td> <td><input name="imageField" type="image" src="images/en/button_search.gif" width="55" height="20" alt="Search" border="0"></td> </tr> </form> </table> <table border="0" cellpadding="2" cellspacing="0" width="230" align="center"> <tr> <td colspan="2" style="padding-top:10px;"><div class="headline_w">Quick Links</div></td> </tr> <tr> <td width="15"><img src="images/bullet.gif" width="13" height="13" border="0"></td> <td width="215"><a href="index.php?page=search" class="w">Advanced Search</a></td> </tr> <tr> <td><img src="images/bullet.gif" width="13" height="13" border="0"></td> <td><a href="index.php?page=new_profiles" class="w">New Profiles</a></td> </tr> <tr> <td><img src="images/bullet.gif" width="13" height="13" border="0"></td> <td><a href="index.php?page=whos_online" class="w">Who's Online</a></td> </tr> <tr> <td><img src="images/bullet.gif" width="13" height="13" border="0"></td> <td><a href="phpBB3" class="w">Members Forum</a></td> </tr> </table> <br /> <br /><br /> here is the advanced search form: <table width="100%" border="0" cellspacing="4" cellpadding="4" bgcolor="#FFFFFF"> <tr> <td class="headline">Easy Search</td> </tr> <tr> <td>Search through thousands of profiles by selecting your criteria below. To search for more specific criteria, continue with the advanced search option below, but if you're too specific, you could limit the results.</td> </tr> <tr> <td> <table width="95%" border="0" cellspacing="1" cellpadding="2" align="center" class="trtc"> <tr> <td colspan="2" height="20" class="trth"> <b> Member Search</b> </td> </tr> <tr> <td valign="top" width="25%" class="trtc"> Find a profile </td> <td width="75%" class="trtc"> <table width="100%" border="0" cellspacing="1" cellpadding="0"> <tr> <td> Member ID </td> <td> Member Name </td> </tr> <tr> <form action="index.php?page=search&search_type=member_code&action=process_search" method=post> <td> <input type="text" name="search_member_code"> <input type="submit" name="Submit" value="Go"> </td> </form> <form action="index.php?page=search&search_type=profile_name&action=process_search" method=post> <td> <input type="text" name="profile_name"> <input type="submit" name="Submit2" value="Go"> </td> </form> </tr> </table> </td> </tr> <tr> <td valign="top" colspan="2" height="20"> </td> </tr> <form action="index.php?page=search&search_type=easy&action=process_search" method=post> <tr> <td valign="top" colspan="2" height="20" class="trth"> <b> Easy Search</b> </td> </tr> <tr> <td valign="top" width="25%" class="trtc"> Gender </td> <td width="50%" class="trtc"> I am {GENDERS_MALE} seeking {GENDERS_FEMALE} </td> </tr> <tr> <td valign="top" width="25%" class="trtc"> Age </td> <td width="75%" class="trtc"> between {AGE_FROM} and {AGE_TO} </td> </tr> <tr> <td valign="top" width="25%" class="trtc"> Country </td> <td width="75%" class="trtc"> {COUNTRIES} </td> </tr> <tr> <td valign="top" width="25%" class="trtc"> State </td> <td width="75%" class="trtc"> {STATES} </td> </tr> <tr> <td valign="top" width="25%" class="trtc"> City / Town </td> <td width="75%" class="trtc"> <input type="text" name="search_city"> </td> </tr> <tr> <td valign="top" width="25%" class="trtc"> Located within</td> <td width="75%" class="trtc"> <select name="search_radius"> <option value="5">5 miles of</option> <option value="10">10 miles of</option> <option value="25">25 miles of</option> <option value="50">50 miles of</option> <option value="100">100 miles of</option> <option value="250">250 miles of</option> <option value="500">500 miles of</option> <option value="50000" selected>500+ miles of</option> </select> </td> </tr> <tr> <td valign="top" width="25%" class="trtc"> Zip/Postal Code</td> <td width="75%" class="trtc"><input type="Text" name="search_zipcode" size="15"></td> </tr> <tr> <td valign="top" width="25%" class="trtc"> Require photo? </td> <td width="75%" class="trtc"> <input type="checkbox" name="search_piconly"> </td> </tr> <tr> <td valign="top" width="25%" class="trtc"> </td> <td width="75%" class="trtc"> <input type="submit" value="Search"> <input type="reset" value="Reset"> </td> </tr> <tr> <td valign="top" width="25%" class="trtc"> </td> <td width="75%" class="trtc"> </td> </tr> </form> <form action="index.php?page=adv_search&search_type=advanced&action=process_search" method=post> <tr> <td valign="top" colspan="2" height="20" class="trth"> <b> Advanced Search</b> </td> </tr> <tr> <td valign="top" width="25%" class="trtc"> Gender </td> <td width="75%" class="trtc"> I am {GENDERS_MALE} seeking {GENDERS_FEMALE} </td> </tr> <tr> <td valign="top" width="25%" class="trtc"> Age </td> <td width="75%" class="trtc"> between {AGE_FROM} and {AGE_TO} </td> </tr> <tr> <td valign="top" width="25%" class="trtc"> Country </td> <td width="75%" class="trtc"> {COUNTRIES} </td> </tr> <tr> <td valign="top" width="25%" class="trtc"> State </td> <td width="75%" class="trtc"> {STATES} </td> </tr> <tr> <td valign="top" width="25%" class="trtc"> City / Town </td> <td width="75%" class="trtc"> <input type="text" name="search_city"> </td> </tr> <tr> <td valign="top" width="25%" class="trtc"> Located within</td> <td width="75%" class="trtc"> <select name="search_radius"> <option value="5">5 miles of</option> <option value="10">10 miles of</option> <option value="25">25 miles of</option> <option value="50">50 miles of</option> <option value="100">100 miles of</option> <option value="250">250 miles of</option> <option value="500">500 miles of</option> <option value="50000" selected>500+ miles of</option> </select> </td> </tr> <tr> <td valign="top" width="25%" class="trtc"> Zip/Postal Code</td> <td width="75%" class="trtc"><input type="Text" name="search_zipcode" size="15"></td> </tr> <tr> <td valign="top" width="25%" class="trtc"> Require photo? </td> <td width="75%" class="trtc"> <input type="checkbox" name="search_piconly"> </td> </tr> <tr> <td colspan="2" height="10" class="trtc"> </td> </tr> <tr> <td valign="top" width="25%" class="trtc"> Race </td> <td width="75%" class="trtc"> {RACES} </td> </tr> <tr> <td colspan="2" height="10" class="trtc"> </td> </tr> <tr> <td valign="top" width="25%" class="trtc"> Marital Status </td> <td width="75%" class="trtc"> {MARITAL_STATUS} </td> </tr> <tr> <td valign="top" width="25%" class="trtc"> Religion </td> <td width="75%" class="trtc"> {RELIGIONS} </td> </tr> <tr> <td colspan="2" height="10" class="trtc"> </td> </tr> <tr> <td valign="top" width="25%" class="trtc"> Drinking </td> <td width="75%" class="trtc"> {DRINKING} </td> </tr> <tr> <td colspan="2" height="10" class="trtc"> </td> </tr> <tr> <td valign="top" width="25%" class="trtc"> Smoking </td> <td width="75%" class="trtc"> {SMOKING} </td> </tr> <tr> <td colspan="2" height="10" class="trtc"> </td> </tr> <tr> <td valign="top" width="25%" class="trtc"> Food </td> <td width="75%" class="trtc"> {FOOD} </td> </tr> <tr> <td colspan="2" height="10" class="trtc"> </td> </tr> <tr> <td valign="top" width="25%" class="trtc"> Occupation </td> <td width="75%" class="trtc"> {OCCUPATIONS} </td> </tr> <tr> <td colspan="2" height="10" class="trtc"> </td> </tr> <tr> <td valign="top" width="25%" class="trtc"> Education </td> <td width="75%" class="trtc"> {EDUCATION} </td> </tr> <tr> <td colspan="2" height="10" class="trtc"> </td> </tr> <tr> <td valign="top" width="25%" class="trtc"> Body Type </td> <td width="75%" class="trtc"> {BODY_TYPES} </td> </tr> <tr> <td colspan="2" height="10" class="trtc"> </td> </tr> <tr> <td valign="top" width="25%" class="trtc"> Eye Color </td> <td width="75%" class="trtc"> {EYE_COLORS} </td> </tr> <tr> <td valign="top" width="25%" class="trtc"> Hair Color </td> <td width="75%" class="trtc"> {HAIR_COLORS} </td> </tr> <tr> <td colspan="2" height="10" class="trtc"> </td> </tr> <tr> <td valign="top" width="25%" class="trtc"> Height </td> <td width="75%" class="trtc"> {HEIGHTS} </td> </tr> <tr> <td colspan="2" height="10" class="trtc"> </td> </tr> <tr> <td valign="top" width="25%" class="trtc"> Languages </td> <td width="75%" class="trtc"> {LANGUAGES} </td> </tr> <tr> <td colspan="2" height="10" class="trtc"> </td> </tr> <tr> <td valign="top" width="25%" class="trtc"> Interests </td> <td width="75%" class="trtc"> {INTERESTS} </td> </tr> <tr> <td colspan="2" height="10" class="trtc"> </td> </tr> <tr> <td valign="top" width="25%" class="trtc"> </td> <td width="75%" class="trtc"> <input type="submit" value="Search"> <input type="reset" value="Reset"> </td> </tr> </form> </table> </td> </tr> </table> <br><br> Link to comment https://forums.phpfreaks.com/topic/146203-php-search-on-my-site-is-acting-strange/#findComment-767573 Share on other sites More sharing options...
Looktrne Posted February 21, 2009 Author Share Posted February 21, 2009 Really need some direction on this please if anyone can take a look and give me any ideas Paul Link to comment https://forums.phpfreaks.com/topic/146203-php-search-on-my-site-is-acting-strange/#findComment-768058 Share on other sites More sharing options...
blueman378 Posted February 22, 2009 Share Posted February 22, 2009 are you using smarty? Link to comment https://forums.phpfreaks.com/topic/146203-php-search-on-my-site-is-acting-strange/#findComment-768164 Share on other sites More sharing options...
Looktrne Posted February 22, 2009 Author Share Posted February 22, 2009 I did not right the script I am just trying to repair the problem. I don't believe it is using smarty.. it appears to be a problem with sessions Paul Link to comment https://forums.phpfreaks.com/topic/146203-php-search-on-my-site-is-acting-strange/#findComment-768209 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.