";
if($submit == "Submit" || $submit == ""){
if($choice == ""){
if($search == "" || $search == "Enter keyword"){
$counter = $size-5;
echo "";
//echo "
";
}
function CountHits($array, $startpt, $topic, $counter)
{
$hits=0;
if($startpt == "") {$startpt = 10;}
$noanswer=0;
for($c=$startpt;$c>0;$c--)
{
if($array[$c]['Answer'] == NULL){
$noanswer++;
}
}
$q=$startpt-$noanswer;
for($i=$startpt;$i>$counter;$i--)
{
if($array[$i]['Answer'] != NULL && preg_match("/$topic/", $array[$i]['Keyword'])){
$q--;
$hits++;
}
if($array[$i]['Answer'] == NULL && $counter!=0){
$counter--;
}
}
echo "Search returned $hits results:
"; } function CountResults($array, $startpt, $topic, $counter) { $hits=0; if($startpt == "") {$startpt = 10;} $noanswer=0; for($c=$startpt;$c>0;$c--) { if($array[$c]['Answer'] == NULL){ $noanswer++; } } $q=$startpt-$noanswer; for($i=$startpt;$i>$counter;$i--) { if(preg_match("/$topic/i", $array[$i]['Question']) || preg_match("/$topic/i", $array[$i]['Answer'])){ $q--; $hits++; } if($array[$i]['Answer'] == NULL && $counter!=0){ $counter--; } } echo "Search returned $hits results:
"; } function DisplayTopic($array, $startpt, $topic, $counter) { echo "";
//echo "
";
}
function DisplaySearch($array, $startpt, $topic, $counter)
{
echo "";
echo "
";
if($q==$startpt-$noanswer) echo "No results found
"; } ?>
Recent Questions
"; DisplayTable($array, $startpt, $counter); } else{ $topic = $search; echo "Search results for '$topic'
"; CountResults($array, $startpt, $topic, $counter); DisplaySearch($array, $startpt, $topic, $counter); } } if($choice != ""){ if($choice == 'all') {echo "All Questions & Answers
"; DisplayTable($array, $startpt, $counter);} if($search == "Enter keyword" && $choice != 'all'){ $topic = $choice; echo "FAQ's about $topic
"; CountHits($array, $startpt, $topic, $counter); DisplayTopic($array, $startpt, $topic, $counter);} if($choice != 'all' && $search != 'Enter keyword') { $topic = $choice; echo "FAQ's about $topic
"; CountHits($array, $startpt, $topic, $counter); DisplayTopic($array, $startpt, $topic, $counter); $topic = $search; echo "Search results for '$topic'
"; CountResults($array, $startpt, $topic, $counter); DisplaySearch($array, $startpt, $topic, $counter);} } } ?> $value) { $array[$j][$colname] = $value; } $j++; } return $array; } function getMax($connection, $TableName) { $query = "SELECT * FROM $TableName WHERE 1"; $result = mysqli_query($connection, $query) or die("Couldn't execute query."); $size = mysqli_num_rows($result); return $size; } function DisplayTable($array, $startpt, $counter) { echo ""; if($firstrow == 0){ echo " | "; } else { echo " | ";
}
echo "Q: {$mess}
A: {$answ} "; //echo " "; echo " |
"; } function CountResults($array, $startpt, $topic, $counter) { $hits=0; if($startpt == "") {$startpt = 10;} $noanswer=0; for($c=$startpt;$c>0;$c--) { if($array[$c]['Answer'] == NULL){ $noanswer++; } } $q=$startpt-$noanswer; for($i=$startpt;$i>$counter;$i--) { if(preg_match("/$topic/i", $array[$i]['Question']) || preg_match("/$topic/i", $array[$i]['Answer'])){ $q--; $hits++; } if($array[$i]['Answer'] == NULL && $counter!=0){ $counter--; } } echo "Search returned $hits results:
"; } function DisplayTopic($array, $startpt, $topic, $counter) { echo "
"; } else { echo " | ";
}
echo "Q: {$mess}
A: {$answ} "; echo " |
"; } else { echo " | ";
}
echo "Q: {$mess}
A: {$answ} "; echo " |
"; } ?>