Source Code Basic PHP Mysqli
>>Combo Box
<?php
$s="select * from `kelas`";
$q=getData($conn,$s);
foreach($q as $d){
$kls_ajar0=$d["kls_ajar"];
$nm_wali=$d["nm_wali"];
echo"<option value='$kls_ajar0' ";if($kls_ajar0==$kls_ajar){echo"selected";} echo">$kls_ajar0 - $nm_wali </option>";
}
?>
=======================================================================================================
>>Function GetData
function getGuru($conn,$kode){
$field="nama_guru";
$sql="SELECT `$field` FROM `guru` where `kd_guru`='$kode'";
$rs=$conn->query($sql);
$rs->data_seek(0);
$row = $rs->fetch_assoc();
$rs->free();
return $row[$field];
}
=============================================================================================================
>>Distinc
<?php
$sqlq="select distinct(kls_ajar) from `$tbpengampu` order by `kd_pengampu` desc";
$jumq=getJum($conn,$sqlq);
if($jumq <1){
echo"<h1>Maaf data belum tersedia...</h1>";
}
$arrq=getData($conn,$sqlq);
foreach($arrq as $dq) {
$kls_ajar=$dq["kls_ajar"];
?>
<h2><a href="#">Data Kelas <?php echo"$kls_ajar";?></a></h2>
<div>
++++++++++++++++++++++++
$sql="select * from `$tbpengampu` where kls_ajar='$kls_ajar' order by `kd_pengampu` desc";
++++++++++++++++++++++++
echo "</div>";
}
?>
</div>
</body>
Javascript Accordion
<?php
$s="select * from `kelas`";
$q=getData($conn,$s);
foreach($q as $d){
$kls_ajar0=$d["kls_ajar"];
$nm_wali=$d["nm_wali"];
echo"<option value='$kls_ajar0' ";if($kls_ajar0==$kls_ajar){echo"selected";} echo">$kls_ajar0 - $nm_wali </option>";
}
?>
=======================================================================================================
>>Function GetData
function getGuru($conn,$kode){
$field="nama_guru";
$sql="SELECT `$field` FROM `guru` where `kd_guru`='$kode'";
$rs=$conn->query($sql);
$rs->data_seek(0);
$row = $rs->fetch_assoc();
$rs->free();
return $row[$field];
}
=============================================================================================================
>>Distinc
<?php
$sqlq="select distinct(kls_ajar) from `$tbpengampu` order by `kd_pengampu` desc";
$jumq=getJum($conn,$sqlq);
if($jumq <1){
echo"<h1>Maaf data belum tersedia...</h1>";
}
$arrq=getData($conn,$sqlq);
foreach($arrq as $dq) {
$kls_ajar=$dq["kls_ajar"];
?>
<h2><a href="#">Data Kelas <?php echo"$kls_ajar";?></a></h2>
<div>
++++++++++++++++++++++++
$sql="select * from `$tbpengampu` where kls_ajar='$kls_ajar' order by `kd_pengampu` desc";
++++++++++++++++++++++++
echo "</div>";
}
?>
</div>
</body>
Javascript Accordion
Posting Komentar untuk "Source Code Basic PHP Mysqli"