fix array

This commit is contained in:
xiaomlove
2021-01-06 01:31:21 +08:00
parent a968b5855c
commit 9bce2ac1a4
17 changed files with 101 additions and 101 deletions
+27 -27
View File
@@ -14,19 +14,19 @@ print("<h1 align=\"center\">FAQ Management</h1>");
// 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];
while ($arr = mysql_fetch_array($res, MYSQLI_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];
$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))
@@ -37,10 +37,10 @@ if (isset($faq_categ))
{
if (!array_key_exists("title", $temp2[$id]))
{
foreach ($temp2[$id][items] as $id2 => $temp)
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];
$faq_orphaned[$lang][$id2]['question'] = $temp2[$id]['items'][$id2]['question'];
$faq_orphaned[$lang][$id2]['flag'] = $temp2[$id]['items'][$id2]['flag'];
unset($temp2[$id]);
}
}
@@ -59,27 +59,27 @@ if (isset($faq_categ))
print("<tr><td align=\"center\" width=\"40px\"><select name=\"order[". $id ."]\">");
for ($n=1; $n <= count($temp2); $n++)
{
$sel = ($n == $temp2[$id][order]) ? " selected=\"selected\"" : "";
$sel = ($n == $temp2[$id]['order']) ? " selected=\"selected\"" : "";
print("<option value=\"$n\"". $sel .">". $n ."</option>");
}
$status = ($temp2[$id][flag] == "0") ? "<font color=\"red\">Hidden</font>" : "Normal";
print("</select></td><td align=\"center\" width=\"40px\">&nbsp;</td><td><b>". $temp2[$id][title] ."</b></td><td align=\"center\" width=\"60px\">". $temp2[$id][lang_name] ."</td><td align=\"center\" width=\"60px\">". $status ."</td><td align=\"center\" width=\"60px\"><a href=\"faqactions.php?action=edit&id=". $temp2[$id][id] ."\">Edit</a> <a href=\"faqactions.php?action=delete&id=". $temp2[$id][id] ."\">Delete</a></td></tr>\n");
$status = ($temp2[$id]['flag'] == "0") ? "<font color=\"red\">Hidden</font>" : "Normal";
print("</select></td><td align=\"center\" width=\"40px\">&nbsp;</td><td><b>". $temp2[$id]['title'] ."</b></td><td align=\"center\" width=\"60px\">". $temp2[$id]['lang_name'] ."</td><td align=\"center\" width=\"60px\">". $status ."</td><td align=\"center\" width=\"60px\"><a href=\"faqactions.php?action=edit&id=". $temp2[$id]['id'] ."\">Edit</a> <a href=\"faqactions.php?action=delete&id=". $temp2[$id]['id'] ."\">Delete</a></td></tr>\n");
if (array_key_exists("items", $temp2[$id]))
{
foreach ($temp2[$id][items] as $id2 => $temp)
foreach ($temp2[$id]['items'] as $id2 => $temp)
{
print("<tr><td align=\"center\" width=\"40px\">&nbsp;</td><td align=\"center\" width=\"40px\"><select name=\"order[". $id2 ."]\">");
for ($n=1; $n <= count($temp2[$id][items]); $n++)
for ($n=1; $n <= count($temp2[$id]['items']); $n++)
{
$sel = ($n == $temp2[$id][items][$id2][order]) ? " selected=\"selected\"" : "";
$sel = ($n == $temp2[$id]['items'][$id2]['order']) ? " selected=\"selected\"" : "";
print("<option value=\"$n\"". $sel .">". $n ."</option>");
}
if ($temp2[$id][items][$id2][flag] == "0") $status = "<font color=\"#FF0000\">Hidden</font>";
elseif ($temp2[$id][items][$id2][flag] == "2") $status = "<font color=\"#0000FF\"><img src=\"pic/updated.png\" alt=\"Updated\" width=\"46\" height=\"11\" align=\"absbottom\"></font>";
elseif ($temp2[$id][items][$id2][flag] == "3") $status = "<font color=\"#008000\"><img src=\"pic/new.png\" alt=\"New\" width=\"27\" height=\"11\" align=\"absbottom\"></font>";
if ($temp2[$id]['items'][$id2]['flag'] == "0") $status = "<font color=\"#FF0000\">Hidden</font>";
elseif ($temp2[$id]['items'][$id2]['flag'] == "2") $status = "<font color=\"#0000FF\"><img src=\"pic/updated.png\" alt=\"Updated\" width=\"46\" height=\"11\" align=\"absbottom\"></font>";
elseif ($temp2[$id]['items'][$id2]['flag'] == "3") $status = "<font color=\"#008000\"><img src=\"pic/new.png\" alt=\"New\" width=\"27\" height=\"11\" align=\"absbottom\"></font>";
else $status = "Normal";
print("</select></td><td>". $temp2[$id][items][$id2][question] ."</td><td align=\"center\"></td><td align=\"center\" width=\"60px\">". $status ."</td><td align=\"center\" width=\"60px\"><a href=\"faqactions.php?action=edit&id=". $id2 ."\">Edit</a> <a href=\"faqactions.php?action=delete&id=". $id2 ."\">Delete</a></td></tr>\n");
print("</select></td><td>". $temp2[$id]['items'][$id2]['question'] ."</td><td align=\"center\"></td><td align=\"center\" width=\"60px\">". $status ."</td><td align=\"center\" width=\"60px\"><a href=\"faqactions.php?action=edit&id=". $id2 ."\">Edit</a> <a href=\"faqactions.php?action=delete&id=". $id2 ."\">Delete</a></td></tr>\n");
}
}
@@ -97,11 +97,11 @@ if (isset($faq_orphaned)) {
foreach ($faq_orphaned as $lang => $temp2){
foreach ($temp2 as $id => $temp)
{
if ($temp2[$id][flag] == "0") $status = "<font color=\"#FF0000\">Hidden</font>";
elseif ($temp2[$id][flag] == "2") $status = "<font color=\"#0000FF\">Updated</font>";
elseif ($temp2[$id][flag] == "3") $status = "<font color=\"#008000\">New</font>";
if ($temp2[$id]['flag'] == "0") $status = "<font color=\"#FF0000\">Hidden</font>";
elseif ($temp2[$id]['flag'] == "2") $status = "<font color=\"#0000FF\">Updated</font>";
elseif ($temp2[$id]['flag'] == "3") $status = "<font color=\"#008000\">New</font>";
else $status = "Normal";
print("<tr><td>". $temp2[$id][question] ."</td><td align=\"center\" width=\"60px\">". $status ."</td><td align=\"center\" width=\"60px\"><a href=\"faqactions.php?action=edit&id=". $id ."\">edit</a> <a href=\"faqactions.php?action=delete&id=". $id ."\">delete</a></td></tr>\n");
print("<tr><td>". $temp2[$id]['question'] ."</td><td align=\"center\" width=\"60px\">". $status ."</td><td align=\"center\" width=\"60px\"><a href=\"faqactions.php?action=edit&id=". $id ."\">edit</a> <a href=\"faqactions.php?action=delete&id=". $id ."\">delete</a></td></tr>\n");
}
}
print("</table>\n");
@@ -111,7 +111,7 @@ print("<br />\n<table border=\"1\" cellspacing=\"0\" cellpadding=\"5\" align=\"c
print("<p align=\"center\"><input type=\"submit\" name=\"reorder\" value=\"Reorder\"></p>\n");
print("</form>\n");
print("<p>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\"</p>");
echo $pagerbottom;
echo $pagerbottom ?? '';
end_main_frame();
stdfoot();