Postingan lainnya
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;
}
?>
2 Jawaban:
Jawaban Terpilih
ngapain fungsi include didalem ahref?? <pre>
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' :
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' <li><a href="'.$link.'" ><i class="fa fa-caret-right"></i> '.$menu['name'].'</a></li> ';
break;
} </pre>
Makasih banyak bang Odhier sukses bisa .......