file load-data.php:
$table = array(
'pemula' => 'table_a',
'semi-pro' => 'table_b',
'pro' => 'table_c'
);
$id = $_GET['id'];
if(!isset($table[$id])){
exit;
}
$conn = mysql_connect("localhost","root","");
mysql_select_db("test");
$sql = "select * from ".$table[$id];
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)){
//tampilkan data
}
file untuk combobox:
<select name="level" id="level">
<option value="">------</option>
<option value="pemula">Pemula</option>
<option value="semi-pro">Semi-Pro</option>
<option value="pro">Profesional</option>
</select>
<div id="data"></div>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
$("#level").change(function(){
var url = 'load-data.php?id='+$(this).val();
$("#data").html('loading....');
$("#data").load(url);
});
});
</script>