<?
// PHP Simple FAQ Search page v0.4
?>
<table border="0" width="100%" cellspacing="2" cellpadding="2">
<tr valign=top align=left>
<td><? echo "<font face=\"$font_face\" size=\"$font_size\" class=\"$font_class\">" ?>
<center><b><? echo "<a class=\"psf\" href=\"index.php\">$main_title</a> > Search Results"; ?></b></center></font></td>
</tr>
</table>
<br>
<center>
<table width="90%" cellpadding="4" cellspacing="2" bgcolor="#333366">
<tr>
<td align="LEFT" bgcolor="#3366CC"><b><? echo "<font face=\"$font_face\" size=\"$font_size\" class=\"$font_class\" color=\"#FFFFFF\"><a class=\"psf\" style=\"color:#FFFFFF\" href=\"index.php\">$main_title</a></font></b></td>"; ?>
</tr>
<?
$sql = "SELECT question_id
FROM $database_name.$question_table
WHERE question LIKE '%$query%'";
$search_result = mysql_query($sql, $connection);
$sql2 = "SELECT q_id
FROM $database_name.$answer_table
WHERE answer LIKE '%$query%'";
$search_result2 = mysql_query($sql2, $connection);
// print_r($search);
if ((mysql_numrows($search_result) == 0) && (mysql_numrows($search_result2) == 0) || (!$query))
{
echo "<tr>\n";
echo "<td align=\"LEFT\" bgcolor=\"#CCCCCC\"><font face=\"$font_face\" size=\"$font_size\" class=\"$font_class\">No records found for <b>$query</b></font></td>\n";
echo "</tr>\n";
} else {
$i = 0;
while ($myrow = mysql_fetch_array($search_result)) {
$new[$i] = $myrow["question_id"];
$i++;
}
while ($myrow = mysql_fetch_array($search_result2)) {
$new[$i] = $myrow["q_id"];
$i++;
}
$search = array_unique($new);
foreach($search as $question_id)
{
$sql3 = "SELECT question, cat_id
FROM $database_name.$question_table
WHERE question_id = '$question_id'";
$result = mysql_query($sql3,$connection);
$myrow2 = mysql_fetch_array($result);
$question = $myrow2["question"];
$cat_id = $myrow2["cat_id"];
if (mysql_numrows($result) != 0)
{
$question = eregi_replace("$query", "<font color=\"#000099\"><b>$query</b></font>", $question);
echo "<tr>\n";
echo "<td align=\"LEFT\" bgcolor=\"#CCCCCC\">\n";
echo "<table width=\"100%\" cellpadding=\"2\" cellspacing=\"0\" border=\"0\">";
echo "<tr>";
echo "<td align=\"LEFT\" bgcolor=\"#CCCCCC\"><font face=\"$font_face\" size=\"$font_size\" class=\"$font_class\"><I>$question</I></font></td>\n";
echo "<td align=\"RIGHT\" bgcolor=\"#CCCCCC\" width=\"100\" valign=\"top\"><font face=\"$font_face\" size=\"$font_size\" class=\"$font_class\" color=\"#ffffff\"><a class=\"psf\" href=\"index.php?action=answers&category=$cat_id&q_id=$question_id\">$answer_this_lang</a></font></td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "</td>\n";
echo "</tr>\n";
$a_get = "SELECT answer
FROM $database_name.$answer_table
WHERE q_id='$question_id'";
$a = mysql_query($a_get, $connection);
while ($myrow5 = mysql_fetch_array($a))
{
$answer = $myrow5["answer"];
$answer = strip_tags($answer, '<b><i>');
$answer = eregi_replace("$query", "<font color=\"#000099\"><b>$query</b></font>", $answer);
echo "<tr>\n";
echo "<td align=\"LEFT\" bgcolor=\"#EEEEEE\"><font face=\"$font_face\" size=\"$font_size\" class=\"$font_class\">$answer</font></td>\n";
echo "</tr>\n";
}
}
}
}
?>
</table>
</center>