Pemberitahuan :

Maaf Atas Ketidak Nyamanan, Blog Ini Sedang Dalam PERBAIKAN !!

English French German Spain Italian Dutch Russian Portuguese Japanese Korean Arabic Chinese Simplified
Translate This Blog by JAS_Blog

Jan 30, 2012

Menampilkan data berdasarkan pilihan di listbox pada PHP

Reactions: 




Alur Program :

  1. Buat koneksi ke database
  2. Buat Form
  3. Fungsi javascript
  4. Proses tampilkan data

Script Koneksi

<?php
$host=”localhost”;
$user=”root”;
$pass=”";
$db=”test”;
//koneksi
$koneksi=mysql_connect($host,$user,$pass);
mysql_select_db($db,$koneksi);
?>

Potongan Script Form

<td width=”241″>
<select multiple=”multiple” name=”id” id=”id” onChange=”pilih(this.value)”>
<?php
$query_limit=mysql_query(“select * from guestbook“);
while($row=mysql_fetch_array($query_limit))
{
?><option value=”<?php  echo $row['id_gb']; ?>”><?php  echo $row['nama']; ?></option><?php
}
?>
</select>
</td>
<td width=”195″ valign=”top”>
<select name=”id” id=”id” onChange=”pilih(this.value)“>
<option value=”0″ selected=”selected”>Pilih Nama</option>
<?php
$query_limit=mysql_query(“select * from guestbook”);
while($row=mysql_fetch_array($query_limit))
{
?><option value=”<?php  echo $row['id_gb']; ?>”><?php  echo $row['nama']; ?></option><?php
}
?>
</select>
</td>

Fungsi Javascript

<script languange=”Javascript1.2″>
function pilih(id){
location.replace(“list-ri32.php?id=”+id);
}
</script>

Script menampilkan data

<?php
include “conn.php”;
if($_GET['']!==”"){
$id=$_GET['id'];
$query=mysql_query(“select * from guestbook where id_gb=’$id’”);
?>
<table border=”1″>
<tr><th>No</th><th>Nama</th><th>Email</th><th>Pesan</th></tr>
<?php
while($row=mysql_fetch_array($query)){
?>
<tr><td><?php echo $c=$c+1;?></td><td><?php echo $row['nama'];?></td><td><?php echo $row['email']; ?></td><td><?php echo $row['pesan']; ?></td></tr>
<?php
}
?></table><?php
}
?>




Sekian artikel dari saya semoga bermanfaat :)

No comments:

Post a Comment

Silahkan Berkomentar Tentang Blog Ini (NO SPAM PLEASE) Agar Blog Ini Bisa Lebih Baik Lagi Dari Yang Sekarang.... TERIMA KASIH & SEMOGA BERMANFAAT :)

EasyHits4U.com - Your Free Traffic Exchange - 1:1 Exchange Ratio, 5-Tier Referral Program. FREE Advertising!

Copyright @ 2013 JAS Blog. Designed by Templateism | Love for The Globe Press