start(); $search_in = array("answer"=>"Answers","q_text"=>"Questions","both"=>"Both"); //SEARCH print ""; print ""; print ""; print "
Search For : "; $curform->displaytext('search_text','','30','50','','',''); print "Search in : "; $curform->displaySelect('search_in', $search_in,'','','','-- SELECT --','',''); print " "; print "
"; print "

"; //SUBJECT print ""; print ""; print ""; print "
Please select a Subject / Category : "; // *********************************************** //get site name and fetch subjects assigned to it. //$host = "www.frlht.org.in"; //$host = "www.homeremedy.in"; //$host = "envis.frlht.org.in"; //print "host: ".$_SERVER['HTTP_HOST']; //GET ELEMENTS SEPERATED BY 'DOT' i.e. '.' $e = explode(".",$_SERVER['HTTP_HOST']); //$e = explode(".",$host); if($e[0]=="www") //USE 2ND ELEMENT AS URL STARTS WITH WWW. { $tmp = $e[1]; } else //USE 1ST ELEMENT AS URL STARTS WITH THE DOMAIN NAME. { $tmp = $e[0]; } //print $temp; //GET SITE ID $siteid = fetch_me("websites","site_id","second_name",$tmp); //GET SUBJECTS RELATED TO THIS SITE $s = "SELECT * FROM subject INNER JOIN subject_site ON subject.sub_id= subject_site.subject_id WHERE subject_site.site_id=$siteid ORDER BY subject.sub_name"; $r = mysql_query($s); $ary = Array(); while($rw=mysql_fetch_array($r)) { $ary[$rw["sub_id"]]=trim($rw["sub_name"]); }//while // *********************************************** //SUBJECT DROPDOWN. $ary IS THE ARRAY OF SUBJECTS $curform->displaySelect('sub_id', $ary,'','','','-- SELECT --','',''); print "
"; print ""; //DISPLAY RESULT if($_POST['search_text']!='') { $msg="YOU ARE LOOKING FOR \"".$_POST['search_text']."\""; if($_POST['search_in']!='') { if($_POST['search_in']=='both') { $q="SELECT * FROM question WHERE q_text LIKE '%".$_POST['search_text']."%' OR answer LIKE '%".$_POST['search_text']."%'"; $sql=mysql_query($q); } else //EITHER QUESTION OR ANSWER { if($_POST['search_in']=='q_text') $in="QUESTIONS"; else $in="ANSWERS"; $msg.=" IN ".$in; $q="SELECT * FROM question WHERE ".$_POST['search_in']." LIKE '%".$_POST['search_text']."%'"; $sql=mysql_query($q); } } else //"SEARCH IN" NOT SPECIFIED { $q="SELECT * FROM question WHERE q_text LIKE '%".$_POST['search_text']."%' OR answer LIKE '%".$_POST['search_text']."%'"; $sql=mysql_query($q); } } //SUBJECT IS SELECTED else if($_POST['sub_id']!='') { $subname=fetch_me("subject","sub_name","sub_id",$_POST['sub_id']); $msg="FAQ's for $subname"; $sql=mysql_query("SELECT * FROM question WHERE sub_id='".$_POST['sub_id']."'"); } //SUBJECT NOT SELECTED HENCE FEATURED FAQ's else { $msg="Featured FAQ's"; $sql=mysql_query("SELECT * FROM question WHERE featured='Y'"); } print ""; print ""; $num=mysql_num_rows($sql); if($num>0) //I.E. SEARCH TEXT FOUND { while($rw=mysql_fetch_object($sql)) { print ""; print ""; } } else if($num==0) //SEARCH TEXT NOT FOUND print ""; ?>
$msg
$rw->q_text
$rw->answer
NO MATCH FOUND