<select name=matkul >
<option value=0 selected><font size="-2">-- mata kuliah --</font></option>
<?php
include 'koneksi_php.php';
$sql=mysql_query("select * from matkul ");
while ($data=mysql_fetch_array($sql)){
echo "<option value=$data[kode]>$data[kode]-$data[nama]</option>";
}
?>
</select>
<select name="matkul">
<option value="0">-- mata kuliah --</option>
<?php
include 'koneksi_php.php';
$sql=mysql_query("select * from matkul ");
while ($data=mysql_fetch_array($sql)){
$selected = '';
if($data['kode'] == $edit){ // $edit -> kode yang diedit
$selected = 'selected="selected"';
}
echo '<option value="'.$data['kode'].'" '.$selected.'>'.$data['kode'].'-'.$data['nama'].'</option>';
}
?>
</select>
variabel $edit diatas adalah variabel imaginer, dimana $edit berisi nilai data yang sedang diedit. <option>pilih</option>
<?php
mysql_connect("localhost", "root", "y2j100794");
mysql_select_db("inv");
$sql = mysql_query("SELECT * FROM tb_master_nama_edp ORDER BY nama_edp ASC");
if(mysql_num_rows($sql) != 0){
while($data = mysql_fetch_assoc($sql)){
echo "<option value=$data[id_nama_edp]>$data[nama_edp]</option>";
}
}
?>
</select>