ExecuteQuery($sql); while(list($celebrant_id)=$res->FetchAsArray()) { $sql_cel_photo = "SELECT photo1, photo2, photo3, thumbnail FROM celebrants WHERE celebrant_id='$celebrant_id' "; $rs_cel_photo = $db->ExecuteQuery($sql_cel_photo); list($photo1, $photo2, $photo3, $thumbnail)=$rs_cel_photo->FetchAsArray(); // for photo $photo=""; if($thumbnail == "p1") { $photo = $photo1; } elseif($thumbnail == "p2") { $photo = $photo2; } elseif($thumbnail == "p3") { $photo = $photo3; } else { $photo = $photo1; } // For Photo Exists Check!! $file = CELEBRANTS_DIR.$photo; if(file_exists($file) && !empty($photo)) { $must_photo_random_cel_ids .= "$celebrant_id, "; // add id only when photo is exists! } } if(!empty($must_photo_random_cel_ids)) { $where_must_photo_random_cel_ids = substr($must_photo_random_cel_ids, 0, strlen($must_photo_random_cel_ids)-2); $where .= " AND c.celebrant_id IN ($where_must_photo_random_cel_ids) "; } } // $sql = "SELECT DISTINCT(c.celebrant_id) FROM celebrants AS c $tables WHERE 1 $where ORDER BY rand()"; if(isset($_SESSION['cr_random_cel_ids'])) { $random_cel_ids = $_SESSION['cr_random_cel_ids']; $random_cel_ids_array = explode(", ", $random_cel_ids); $random_rows = count($random_cel_ids_array); } else { if($is_photo=="Yes") { $random_cel_ids = $must_photo_random_cel_ids; } else { $res = $db->ExecuteQuery($sql); while(list($celebrant_id)=$res->FetchAsArray()) { $random_cel_ids .= "$celebrant_id, "; } } if(!empty($random_cel_ids)) { $random_cel_ids = substr($random_cel_ids, 0, strlen($random_cel_ids)-2); $random_cel_ids_array = explode(", ", $random_cel_ids); $random_rows = count($random_cel_ids_array); $_SESSION['cr_random_cel_ids'] = $random_cel_ids; } } // /* echo "
SQL: ".$sql."
"; echo "
Random IDs: ".$random_cel_ids."
"; echo "
Random Rows: ".$random_rows."
"; */ // exit; ?>

Celebrant Search Results

    ExecuteQuery($sql); $recperpage = 15; include "library/page_config.php"; $cnt=0; $record_show=0; $i = $jmpcnt-1; if($rcount > 0) { while((list($celebrant_id)=$res->FetchAsArray()) && ($cnt<$recperpage)) { // get celebrant id from array if($random_rows > 0) { $celebrant_id = $random_cel_ids_array[$i++]; } // get celebrant info $sql_celberant_info = "SELECT email, first_name, last_name, gender, street_address, subrub, state, zipcode, postal_address, phone, mobile, search_txt, profile_txt, photo1, photo2, photo3, thumbnail FROM celebrants WHERE celebrant_id='$celebrant_id' "; $res_celberant_info = $db->ExecuteQuery($sql_celberant_info); list($email, $first_name, $last_name, $gender, $street_address, $subrub, $state, $zipcode, $postal_address, $phone, $mobile, $search_txt, $profile_txt, $photo1, $photo2, $photo3, $thumbnail)=$res_celberant_info->FetchAsArray(); // // For Celebrant Search Stats if(isset($_SESSION['celebrants_search_stats'])) { if(is_array($_SESSION['celebrants_search_stats'])) { if(!in_array($celebrant_id, $_SESSION['celebrants_search_stats'])) { $_SESSION['celebrants_search_stats'][] = $celebrant_id; // Insert into profile searches $sql_insert_searches = "INSERT INTO celebrants_search_stats (celebrant_id, search_date) VALUES ('$celebrant_id', now()) "; $db->ExecuteQuery($sql_insert_searches); // } } } else { $_SESSION['celebrants_search_stats'][] = $celebrant_id; // Insert into profile searches $sql_insert_searches = "INSERT INTO celebrants_search_stats (celebrant_id, search_date) VALUES ('$celebrant_id', now()) "; //-->$db->ExecuteQuery($sql_insert_searches); // } // $name = $first_name." ".$last_name; if(strlen($search_txt) > 250) $search_txt = substr($search_txt,0, 250)."...."; $search_txt = nl2br($search_txt); $cnt++;?>