PDA

View Full Version : FaqMasterFlex - sorting


Sonia
06-28-2005, 07:16 PM
I'm using one of the addon scripts, FaqMasterFlex (http://www.technetguru.net/design/faqmasterflex.php) . It works beautifully, except for one thing - there's no way to sort the questions. It just lists them in the order I enter them. I want them listed alphabetically.

Here's the code for the list of questions and answers:


<?php


include "faq_config.php";

$result = mysql_query("SELECT * FROM faqs WHERE category_id = '$category_id'");



while ($row = mysql_fetch_array($result)) {

if (($answer == "$row[id]") || ($print == "true")) {

print "<tr>
<td class=\"QA\" valign=\"top\">Q <a name=\"$answer\"></a></td>
<td><pre class=\"question\"><a href=\"$PHP_SELF?answer=0&cat_name=$cat_name&category_id=$category_id\">$row[question]</a></pre></td>
</tr>\n";

print "<tr>
<td class=\"QA\" valign=\"top\">A</td>
<td><pre class=\"answer\">$row[answer]</pre>
<br>
<a href=\"$PHP_SELF?answer=0&cat_name=$cat_name&category_id=$category_id#$answer\">&times; close</a><br></td>
</tr>\n";
}


else {

print "<tr>
<td class=\"QA\" valign=\"top\">Q <a name=\"$row[id]\"></td>
<td><pre class=\"question\"><a href=\"$PHP_SELF?answer=$row[id]&cat_name=$cat_name&category_id=$category_id#$row[id]\">$row[question]</a></pre></td>
</tr>\n";
}


}


mysql_close($link);

?>

Does anyone know how I could sort these questions alphabetically? I'm a newbie to PHP, and don't really know how to pick apart the code. Thank you!