Selamat Malam Agan-Agan Master.

Newbiew nii..
mau tanya bagaimana cara menampilkan gambar dari database berdasarkan pilihan dari combobox.

ni kode aku gan
<?php    
// Koneksi  
mysql_connect("localhost","root","");    
mysql_select_db("sgat");  
//$kdtg=$_POST["$id"];
$result = mysql_query("select * from t_reg_truk where (T_QRCODE_ID ='' OR T_QRCODE_ID IS NULL) AND (Kdtg_ID='$id') ORDER BY TIME ASC");  
$jsArray = "var Name = new Array();\n";
//$jsArray2 = "var Name = new Array();\n";

echo '<select name="license" onchange="document.getElementById(\'Supir\').value = Name[this.value]">';  
//echo '<option>-------</option>';  
while ($row = mysql_fetch_array($result)) {  
    echo '<option value="' . $row['Nopol'] . '">' . $row['Nopol'] . '</option>';  
	//$jsArray .= "Name['" . $row['Nopol'] . "'] = {'" . addslashes($row['Supir']) . "',desc:'".addslashes($row['Supir_Img'])."'};\n";
    $jsArray .= "Name['" . $row['Nopol'] . "'] = '" . addslashes($row['Supir']) . "';\n";  
 	$jsArray2 .= "Name['" . $row['Nopol'] . "'] = '" . addslashes($row['Supir_Img']) . "';\n";   
 }  
echo '</select>';  
?>  
              </td>
              <td rowspan="5" align="center">
<img src="saved_images/<? echo $jsArray2; ?>" border="3" /> <td>
            </tr>
            <tr>
  <td height="24">Nama Supir</td> <td>:</td> <td><input readonly type="text" name="driver" id="Supir"/>  
    <script type="text/javascript">  
<?php echo $jsArray; ?> 

mohon bantuannya ya gan......
Silahkan login untuk menjawab!
0
Loading...
Lilyzz Ayuna Anggreani · Sep 29, 2014 · 0 Suka · 0 Tidak Suka
Update kode gan
<tr>
              <td>No Polisi </td>
              <td>:</td>
              <td><?php    
// Koneksi  
mysql_connect("localhost","root","bajigur12");    
mysql_select_db("sga");  
//$kdtg=$_POST["$id"];
$result = mysql_query("select * from t_reg_truk where (T_QRCODE_ID ='' OR T_QRCODE_ID IS NULL) AND (Kdtg_ID='$id') ORDER BY TIME ASC");  
$jsArray = "var Name = new Array();\n";
//$jsArray2 = "var Name = new Array();\n";

echo '<select name="license" onchange="document.getElementById(\'Supir\').value = Name[this.value]">';  
//echo '<option>-------</option>';  
while ($row = mysql_fetch_array($result)) {  
    echo '<option value="' . $row['Nopol'] . '">' . $row['Nopol'] . '</option>';  
	//$jsArray .= "Name['" . $row['Nopol'] . "'] = {'" . addslashes($row['Supir']) . "',desc:'".addslashes($row['Supir_Img'])."'};\n";
    $jsArray .= "Name['" . $row['Nopol'] . "'] = '" . addslashes($row['Supir']) . "';\n";  
 	$jsArray2 .= "Name['" . $row['Nopol'] . "'] = '" . addslashes($row['Supir_Img']) . "';\n";   
 }  
echo '</select>';  
?>  
              </td>
              <td rowspan="5" align="center">
<img src="saved_images/<? echo $jsArray2; ?>" border="3" /> <td>
            </tr>
            <tr>
  <td height="24">Nama Supir</td> <td>:</td> <td><input readonly type="text" name="driver" id="Supir"/>  
    <script type="text/javascript">  
<?php echo $jsArray; ?> 

</script>  </td>
</tr>