Postingan lainnya
bagaimana membuat switch case tapi data dari database
<?php
switch ($i) {
case "apple":
echo "i is apple";
break;
case "bar":
echo "i is bar";
break;
case "cake":
echo "i is cake";
break;
}
?>
7 Jawaban:
<pre> SELECT (CASE WHEN id = "apple" THEN "i is apple" WHEN id = "bar" THEN "i is bar" WHEN id = "cake" THEN "i is cake" END) AS item FROM tableName </pre>
<pre> <?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 ='".$uid."' or ar_tid ='".$grp."' ) ");
while ($datasubmenu = mssql_fetch_assoc($sql)){
echo '
<li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown"> <i class="fa fa-folder"></i>'.$datasubmenu['name'].'<b class="fa fa-plus dropdown-plus"></b> </a>'; while ($datasubmenu = mssql_fetch_assoc($sql)){
echo ' <ul class="dropdown-menu"> <li class="dropdown">
&lt;a href="#" class="dropdown-toggle" data-toggle="dropdown"&gt;
&lt;i class="fa fa-folder"&gt;&lt;/i&gt; '.$datasubmenu['name'].'&lt;b class="fa fa-plus dropdown-plus"&gt; &lt;/b&gt;
&lt;/a&gt;
<ul class="dropdown-menu"> '; while ($datasubmenu = mssql_fetch_assoc($sql)){
echo '
&lt;li&gt;&lt;a href="
&lt;? SELECT (case when xh = "10120110" THEN
"chart.php"
when xh = "10120120" THEN
"blank_page"
when xh = "10120150" THEN
"chart2.php"
when xh = "10120160" THEN
"chart3.php"
END) AS xh FROM [APPL_NAVI] ?&gt;
<i class="fa fa-caret-right"></i> '.$datasubmenu['name'].'</a></li> '; echo' </li>';
}
}
}
?> </pre> udah saya coba gan tapi gak berhasil link tidak berjalan
<a href=' https://drive.google.com/open?id=1fpe2Exhdvs6LTA7LtvK757c0oKlGnlO2 '> https://drive.google.com/open?id=1fpe2Exhdvs6LTA7LtvK757c0oKlGnlO2 </a>
kaya gini bang
Itu url nya yg salah mas /home/<?=....
Url nya err, itu tag php nya nongol di url, coba mana script bagian nampilin href nya..
mas itu masukin script yang mas kasih simpan nya di dalam href apa dimana ?