I'm working on a project and have run into something that for my current level of PHP knowledge, would take me a while to figure out. If you can offer any help/tips it would be much appreciated

Current related code:
[]
$cats = array(1,2);
unset($cats);
$mice = array(1=>array(1,2));
unset($mice[0]);
unset($mice[1]);
// Gather the needed FAQs
$result = mysql_query("SELECT uid,title FROM faq WHERE (is_private = 0 AND approved_date_time = '0000-00-00 00:00:00') || (is_private = 1 AND author_uid = " . $rid . ");");
for ($i = 0; $i < mysql_num_rows($result); $i++) {
list($uid,$title) = mysql_fetch_row($result);
$cats[$uid] = $title;
}
// For each FAQ that was gathered above, get the category_tree_uid
foreach($cats as $key => $value) {
$khalif = mysql_query("SELECT category_tree_uid FROM faq_category WHERE faq_uid = " . $key . ";");
if(mysql_num_rows($khalif)) {
for ($i = 0; $i < mysql_num_rows($khalif); $i++) {
list($category_tree_uid) = mysql_fetch_row($khalif);
// See if the reseller is subscribed to this category
$res = mysql_query("SELECT user_uid FROM user_sub WHERE user_uid = " . $rid . " AND category_tree_uid = " . $category_tree_uid . ";");
if(mysql_num_rows($res)) {
$mice[$category_tree_uid][$key] = $value;
}
}
}
}
$fight = array(1,2);
unset($fight);
foreach($mice as $key => $value) {
$vizier = mysql_query("SELECT name FROM category_tree WHERE uid = " . $key . ";");
list($category) = mysql_fetch_row($vizier);
?>
<h2><?=$category?></h2>
<?
$fight = $value;
foreach($value as $keys => $values) {
$linkme = $keys;
$title = $values;
?>
<a href="display-faq-detail.php?id=<?=$linkme?>"><?=$title?></a><br>
<?
}
}
[/]
Pseudocode I've come up with:
[]
// For each FAQ - We need to load these types of information into array(s)
category_name <- name of the FAQ's parent category
category_tree_uid <- id number for the FAQ's parent category
key <- id number for the specific FAQ
title <- title of the FAQ
// Need to sort individual FAQs by category_name, regardless of it's category_tree_uid
// Need to output each FAQ:
// Display the category_name only once for each group of FAQs with identical category_name
// Print link/title
[/]
Main things are getting the info into arrays, sorting while keeping related data for each FAQ grouped, cycling through array to print out info.
Thanks again for any help.
