FAQ Management"); // make the array that has all the faq in a nice structured $res = sql_query("SELECT faq.id, faq.link_id, faq.lang_id, lang_name, faq.question, faq.flag, faq.order FROM faq LEFT JOIN language on faq.lang_id = language.id WHERE type='categ' ORDER BY lang_name, `order` ASC"); while ($arr = mysql_fetch_array($res, MYSQL_BOTH)) { $faq_categ[$arr[lang_id]][$arr[link_id]][title] = $arr[question]; $faq_categ[$arr[lang_id]][$arr[link_id]][flag] = $arr[flag]; $faq_categ[$arr[lang_id]][$arr[link_id]][order] = $arr[order]; $faq_categ[$arr[lang_id]][$arr[link_id]][id] = $arr[id]; $faq_categ[$arr[lang_id]][$arr[link_id]][lang_name] = $arr[lang_name]; } $res = sql_query("SELECT faq.id, faq.question, faq.lang_id, faq.flag, faq.categ, faq.order FROM faq WHERE type='item' ORDER BY `order` ASC"); while ($arr = mysql_fetch_array($res)) { $faq_categ[$arr[lang_id]][$arr[categ]][items][$arr[id]][question] = $arr[question]; $faq_categ[$arr[lang_id]][$arr[categ]][items][$arr[id]][flag] = $arr[flag]; $faq_categ[$arr[lang_id]][$arr[categ]][items][$arr[id]][order] = $arr[order]; } if (isset($faq_categ)) { // gather orphaned items foreach ($faq_categ as $lang => $temp2){ foreach ($temp2 as $id => $temp) { if (!array_key_exists("title", $temp2[$id])) { foreach ($temp2[$id][items] as $id2 => $temp) { $faq_orphaned[$lang][$id2][question] = $temp2[$id][items][$id2][question]; $faq_orphaned[$lang][$id2][flag] = $temp2[$id][items][$id2][flag]; unset($temp2[$id]); } } } } // print the faq table print("
"); foreach ($faq_categ as $lang => $temp2) { foreach ($temp2 as $id => $temp) { print("
\n\n"); print("\n"); print("\n"); if (array_key_exists("items", $temp2[$id])) { foreach ($temp2[$id][items] as $id2 => $temp) { print("\n"); } } print("\n"); print("
PositionSection/Item TitleLanguageStatusActions
 ". $temp2[$id][title] ."". $temp2[$id][lang_name] ."". $status ."Edit Delete
 ". $temp2[$id][items][$id2][question] ."". $status ."Edit Delete
Add new item
\n"); } } } // print the orphaned items table if (isset($faq_orphaned)) { print("
\n\n"); print("\n"); print("\n"); foreach ($faq_orphaned as $lang => $temp2){ foreach ($temp2 as $id => $temp) { if ($temp2[$id][flag] == "0") $status = "Hidden"; elseif ($temp2[$id][flag] == "2") $status = "Updated"; elseif ($temp2[$id][flag] == "3") $status = "New"; else $status = "Normal"; print("\n"); } } print("
Orphaned Items
Item TitleStatusActions
". $temp2[$id][question] ."". $status ."edit delete
\n"); } print("
\n\n\n
Add new section
\n"); print("

\n"); print("
\n"); print("

When the position numbers don't reflect the position in the table, it means the order id is bigger than the total number of sections/items and you should check all the order id's in the table and click \"reorder\"

"); echo $pagerbottom; end_main_frame(); stdfoot(); ?>