<?
include "header.php";
echo $header;


$isfaqon = mysql_fetch_assoc(mysql_query("SELECT faq_on FROM ims_admin"));
if($isfaqon[faq_on] == "no") {
echo "
<table cellpadding='0' cellspacing='0' width='520'>
<tr><td>
<b>An Error Has Occurred:</b><br>
Sorry, the FAQ page has been disabled by the administrator.
</td></tr>
</table>
";
echo $footer;
exit();
}


if(isset($_GET['q_id'])) { $q_id = $_GET['q_id']; }



if($q_id != "") {
$question_query = mysql_query("SELECT * FROM ims_faq WHERE q_id='$q_id'");
$question = mysql_fetch_assoc($question_query);
if(mysql_num_rows($question_query) == 0) {
echo "<b>An error has occurred</b><br>
You are attempting to view an invalid FAQ question.
";
}

echo "
<table width='520' cellpadding='0' cellspacing='0'>
<tr><td>
<b>$question[question]</b><br>
$question[answer]
</td></tr></table>
<br>
<table cellpadding='0' cellspacing='0'>
<tr><form action='support_faq.php' method='POST'><td><input type='submit' class='button' value='Back to FAQ'></td></form></tr>
</table>
";




} else {





echo "
<table width='520' cellpadding='0' cellspacing='0'>
<tr>
<td>
<b>Frequently Asked Questions (FAQ)</b><br>
";

$faq_questions = mysql_query("SELECT * FROM ims_faq");
$numofquestions = mysql_num_rows($faq_questions);

if($numofquestions > 0) {
echo "
Welcome to the FAQ Knowledge Base. The answers to our most
frequently asked questions<br> are listed below. To get started, click a
question that is most relevant to your issue.
</td>
</tr>
</table>
<br>
";
} else {
echo "
Sorry, there are no FAQ questions for you to browse yet. Please check back at a later time
<br><br>
<table cellpadding='0' cellspacing='0'>
<tr>
<form action='support.php' method='POST'><td><input class='button' type='submit' value='Return to Support'></td></form>
</tr>
</table>
</td>
</tr>
</table>
";

echo $footer;
exit();
}

$counter = 0;
$faqcat = mysql_query("SELECT * FROM ims_faqcat ORDER BY c_order");
$num_of_kitties = mysql_num_rows($faqcat);
while($faqcat_info = mysql_fetch_assoc($faqcat)) {
$counter++;
echo "
<table width='520' cellpadding='0' cellspacing='0' style='border: 1px solid #AAAAAA; background: #FFFFFF;"; if($counter != $num_of_kitties) { echo " margin-bottom: 8px;"; } echo "'>
<tr>
<td style='padding: 5px; padding-top: 2px;'>
<b>$faqcat_info[category]</b><br>
";
$count = 0;
$questions1 = mysql_query("SELECT q_id, c_id, question FROM ims_faq WHERE c_id='$faqcat_info[c_id]' ORDER BY q_order");
while($question = mysql_fetch_assoc($questions1)) {
$count++;
echo "$count. <a href='support_faq.php?q_id=$question[q_id]'>$question[question]</a><br>";
}
echo "
</td>
</tr>
</table>
";
}

}



echo $footer;
?>