<div class="modal-body"> <div class="form-group"> <label>Pindah Parent ke</label> <select class="form-control pilih-parent" name="parent"> <option value="0">Paling atas</option> <?php if ($array_semuamenu) { foreach ($array_semuamenu as $semuamenu) { if ($semuamenu) { ?> <option value="<?php echo $semuamenu['id']; ?> "> <?php $text_menu = TextMenu($semuamenu['route'], $semuamenu['menu'], $semuamenu['idpost'], $conn, $bhs_on); if ($semuamenu['text'] != "") { $text_menu = $semuamenu['text']; } echo $text_menu; ?> </option> <?php } } } ?> </select> <input id="tujuan-id-edit" type="hidden" name="id" /> </div> <div class="form-group">
function SubMenu($parent, $conn, $bhs_on, $link_source) { $sql = "SELECT * FROM menu WHERE parent='{$parent}' ORDER BY urutan ASC"; $result = $conn->query($sql); $ListTabel = NULL; while ($row = $result->fetch_assoc()) { $text_menu = TextMenu($row['route'], $row['menu'], $row['idpost'], $conn, $bhs_on); if ($row['text'] != "") { $text_menu = $row['text']; } $ListTabel[] = array("id" => $row['id'], "parent" => $row['parent'], "text" => $text_menu, "urutan" => $row['urutan'], "link" => LinkAlt($row['link'] == 1, AutoLink($link_source, $row['route'], $row['menu'], $row['idpost'], "", ""), "#")); } return $ListTabel; }
if ($array_semuamenu) { foreach ($array_semuamenu as $semuamenu) { if ($semuamenu) { $menuparent[] = array("id" => $semuamenu['id'], "text" => TextMenu($semuamenu['route'], $semuamenu['menu'], $semuamenu['idpost'], $conn, $bhs_on)); $sql = "SELECT * FROM menu WHERE id_menu='{$idpost}' AND parent='" . $semuamenu['id'] . "' ORDER BY urutan ASC"; $array_semuamenu_2 = RowData($sql, $conn); if ($array_semuamenu_2) { foreach ($array_semuamenu_2 as $semuamenu_2) { if ($semuamenu_2) { $menuparent[] = array("id" => $semuamenu_2['id'], "text" => TextMenu($semuamenu['route'], $semuamenu['menu'], $semuamenu['idpost'], $conn, $bhs_on) . " > " . TextMenu($semuamenu_2['route'], $semuamenu_2['menu'], $semuamenu_2['idpost'], $conn, $bhs_on)); $sql = "SELECT * FROM menu WHERE id_menu='{$idpost}' AND parent='" . $semuamenu_2['id'] . "' ORDER BY urutan ASC"; $array_semuamenu_3 = RowData($sql, $conn); if ($array_semuamenu_3) { foreach ($array_semuamenu_3 as $semuamenu_3) { if ($semuamenu_3) { $menuparent[] = array("id" => $semuamenu_3['id'], "text" => TextMenu($semuamenu['route'], $semuamenu['menu'], $semuamenu['idpost'], $conn, $bhs_on) . " > " . TextMenu($semuamenu_2['route'], $semuamenu_2['menu'], $semuamenu_2['idpost'], $conn, $bhs_on) . " > " . TextMenu($semuamenu_3['route'], $semuamenu_3['menu'], $semuamenu_3['idpost'], $conn, $bhs_on)); } } } } } } } } } $sql = "SELECT * FROM main_menu WHERE id='{$idpost}'"; $nama_menu = TampilData($sql, $conn); } if (isset($_POST['add-main-menu'])) { $namamenu = FormSet($_POST['nama']); $sql = "INSERT INTO main_menu (nama) VALUES ('{$namamenu}')";