ada yang tau memanggil switch case?

mau bertanya gan caranya memanggil switch case menu supaya bisa kepanggil di link menu nya gimana yah gan,,, menu nya ane panggil dari database...

 <?php


$uid = $_SESSION['uid'];
$grp = $_SESSION['grp'];

include 'conection.php';
$sql=mssql_query("SELECT  xh,name,flag FROM [appl_navi] JOIN [appl_role] on xh = ar_xh where flag>0 and
(ar_uid ='sh' or ar_tid ='sys' ) ");

while ($menu = mssql_fetch_assoc($sql)){

switch ($menu["flag"])
{
case '1' :

   echo'
   <li class="dropdown">
    <a href="#" class="dropdown-toggle" data-toggle="dropdown">
    <i class="fa fa-folder"></i>'.$menu['name'].'<b class="fa fa-plus dropdown-plus"></b></a> <ul class="dropdown-menu"> ';

 break;
case '2' :

   echo'
   <li><a href="PANGGIL ID SWITCHCASE NYA DISINI" ><i class="fa fa-caret-right"></i> '.$menu['name'].'</a></li> ';

 break;

}
}
------------------YANG INI GAN APA BISA SWITCHCASE DI KASIH ID MISAL NYA DI KASIH VARIABLE
JADI NANTI VARIABLE NYA DI MASUKIN KEDALAM HREFF...... ADA YG TAU CARA PENULISAN VARIABLE NYA


switch  ($menu["xh"])

{
    case "10120110":
	include ("page1.php");
        break;
    case "10120120":
	include ("page2.php");
        break;
    case "10120150":
	include ("page3.php");
        break;
    case "10120160":
	include ("page4.php");
        break;

}

?>
avatar Obbytokun
@Obbytokun

186 Kontribusi 16 Poin

Diperbarui 6 tahun yang lalu

2 Jawaban:

Jawaban Terpilih

ngapain fungsi include didalem ahref?? <pre>

switch ($menu["flag"]) { case '1' :

echo' &lt;li class="dropdown"&gt; &lt;a href="#" class="dropdown-toggle" data-toggle="dropdown"&gt; &lt;i class="fa fa-folder"&gt;&lt;/i&gt;'.$menu['name'].'&lt;b class="fa fa-plus dropdown-plus"&gt;&lt;/b&gt;&lt;/a&gt; &lt;ul class="dropdown-menu"&gt; ';

break; case '2' :

switch ($menu["xh"]) { case "10120110": $link = "page1.php"; break; case "10120120": $link = "page2.php"; break; case "10120150":
$link = "page3.php"; break; case "10120160": $link = "page2.php"; break;

} echo' &lt;li&gt;&lt;a href="'.$link.'" &gt;&lt;i class="fa fa-caret-right"&gt;&lt;/i&gt; '.$menu['name'].'&lt;/a&gt;&lt;/li&gt; ';

break;

} </pre>

avatar odhier
@odhier

38 Kontribusi 24 Poin

Dipost 6 tahun yang lalu

Makasih banyak bang Odhier sukses bisa .......

avatar Obbytokun
@Obbytokun

186 Kontribusi 16 Poin

Dipost 6 tahun yang lalu

Login untuk ikut Jawaban