Hi,
I'm trying to modify the faq from php-nuke so it will work without php-nuke and there's this one piece of code that's missing and I was wondering if anyone could fill in the gap or give me an idea of what needs to be used.
The problem is that when I click on a category I get a 404. All of the functions are there, but I need to know how to get the questions to show up. Here's the source followed by the db dump (if anyone needs it).
<?
$dbhost = "localhost";
$dbuname = "root";
$dbpass = "";
$dbname = "Faq";
Mysql_connect($dbhost, $dbuname, $dbpass);
Mysql_select_db($dbname);
$bgcolor1 = "#cccccc";
$bgcolor2 = "#999999";
function OpenTable() {
global $bgcolor1, $bgcolor2;
echo "<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\" bgcolor=\"$bgcolor2\"><tr><td>\n";
echo "<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"8\" bgcolor=\"$bgcolor1\"><tr><td>\n";
}
function CloseTable() {
echo "</td></tr></table></td></tr></table>\n";
}
function ShowFaq($id_cat, $categories) {
OpenTable();
echo"<center><font class=\"content\"><b>FAQ (Frequently Asked Questions)</b></font></center><br><br>"
."<a name=\"top\"></a><br>" / Bug fix : added missing closing hyperlink tag messes up display /
."Category: <a href=\"faq.php\">Main</a> -> $categories"
."<br><br>"
."<table width=\"100%\" cellpadding=\"4\" cellspacing=\"0\" border=\"0\">"
."<tr bgcolor=\"$bgcolor2\"><td colspan=\"2\"><font class=\"option\"><b>Question</b></font></td></tr><tr><td colspan=\"2\">";
$result = Mysql_query("select id, id_cat, question, answer from faqAnswer where id_cat='$id_cat'");
while(list($id, $id_cat, $question, $answer) = Mysql_fetch_row($result)) {
echo"<strong><big>·</big></strong> <a href=\"#$id\">$question</a><br>";
}
echo "</td></tr></table>
<br>";
}
function ShowFaqAll($id_cat) {
echo "<table width=\"100%\" cellpadding=\"4\" cellspacing=\"0\" border=\"0\">"
."<tr bgcolor=\"$bgcolor2\"><td colspan=\"2\"><font class=\"option\"><b>Answer</b></font></td></tr>";
$result = Mysql_query("select id, id_cat, question, answer from faqAnswer where id_cat='$id_cat'");
while(list($id, $id_cat, $question, $answer) = Mysql_fetch_row($result)) {
echo"<tr><td><a name=\"$id\"></a>"
."<strong><big>·</big></strong> <b>$question</b>"
."<p align=\"justify\">$answer</p>"
."[ <a href=\"#top\">Back to Top</a> ]"
."<br><br>"
."</td></tr>";
}
echo "</table><br><br>"
."<div align=\"center\"><b>[ <a href=\"faq.php\">Back to FAQ Index</a> ]</b></div>";
}
if (!$myfaq) {
OpenTable();
echo "<center><font class=\"option\">FAQ (Frequently Asked Questions)</font></center><br><br>"
."<table width=\"100%\" cellpadding=\"4\" cellspacing=\"0\" border=\"0\">"
."<tr><td bgcolor=\"$bgcolor2\"><font class=\"option\"><b>Categories</b></font></td></tr><tr><td>";
$result = Mysql_query("select id_cat, categories from faqCategories");
while(list($id_cat, $categories) = Mysql_fetch_row($result)) {
$catname = urlencode($categories);
echo"<strong><big>·</big></strong> <a href=\"faq.php?id_cat=$id_cat&categories=$catname\">$categories</a><br>";
}
echo "</td></tr></table>";
CloseTable();
}
else {
ShowFaq($id_cat, $categories);
ShowFaqAll($id_cat);
CloseTable();
}
?>
Table structure for table faqanswer
CREATE TABLE faqanswer (
id tinyint(4) NOT NULL auto_increment,
id_cat tinyint(4) default NULL,
question varchar(255) default NULL,
answer text,
PRIMARY KEY (id)
) TYPE=MyISAM;
--------------------------------------------------------
Table structure for table faqcategories
CREATE TABLE faqcategories (
id_cat tinyint(3) NOT NULL auto_increment,
categories varchar(255) default NULL,
PRIMARY KEY (id_cat)
) TYPE=MyISAM;