<?php include "koneksi.php" ?>
<?php
$result = mysql_query("select * from sales");
$jsArray = "var slsName = new Array();\n";
echo '<select name="slsId" onchange="changeValue(this.value)">';
echo '<option>Pilih Nama Sales</option>';
while ($row = mysql_fetch_array($result)) {
echo '<option value="' . $row['id_sales'] . '">' . $row['nama_sales'] . '</option>';
$jsArray .= "slsName['" . $row['id_sales'] . "'] = {ids:'".addslashes($row['id_sales'])."'};\n";
}
echo '</select>';
?>
<script type="text/javascript">
<?php echo $jsArray; ?>
function changeValue(id){
document.getElementById('sls_id').value = slsName[id].ids;
};
</script>
<input type="text" name="sls_name" id="sls_id"/>
<?php
$result = mysql_query("select * from costumer");
$jsArray = "var prdName = new Array();\n";
echo '<select name="prdId" onchange="changeValue(this.value)">';
echo '<option>Pilih Nama Company</option>';
while ($row = mysql_fetch_array($result)) {
echo '<option value="' . $row['id_costumer'] . '">' . $row['nama_costumer'] . '</option>';
$jsArray .= "prdName['" . $row['id_costumer'] . "'] = {att:'".addslashes($row['attention'])."',alt:'" . addslashes($row['alamat']) . "',telp:'" . addslashes($row['telepon']) . "',psot:'".addslashes($row['posisi'])."',id:'".addslashes($row['id_costumer'])."'};\n";
}
echo '</select>';
?>
<script type="text/javascript">
<?php echo $jsArray; ?>
function changeValue(id){
document.getElementById('cst_almt').value = prdName[id].alt;
document.getElementById('cst_atte').value = prdName[id].att;
document.getElementById('cst_telp').value = prdName[id].telp;
document.getElementById('cst_psot').value = prdName[id].psot;
document.getElementById('cst_id').value = prdName[id].id;
};
</script>
<input type="text" name="prod_name" id="cst_almt"/>
<input type="text" name="prod_desc" id="cst_atte"/>
<input type="text" name="prod_name" id="cst_telp"/>
<input type="text" name="prod_desc" id="cst_psot"/>
<input type="text" name="prod_name" id="cst_id"/>
<?php
$query = "select * from lab where id='".mysql_real_escape_string($_GET['id'])."'";
$result = mysql_query($query);
$hasil = mysql_fetch_array($result);
?>
<td><label for="jenis" class="labelfrm">Jenis</label></td>
<td>
<select name="jenis">
<?php
$tampil=("SELECT * FROM jenis");
$query_hasil=mysql_query($tampil);
while($r=mysql_fetch_object($query_hasil))
{
if ($hasil[jenis] == $r[Id_jenis])
{
echo "<option value=$r->id_jenis>$r->jenis</option>";
}
else
{
echo "<option value=$r->id_jenis>$r->jenis</option>";
}
}
?>
</select>
</td>
<p><label for="isi_penghuni">Isi Penghuni</label>
<input type="text" name = "angka" size="50" maxlength="10" onkeypress="return harusangka(event)"></input><br /></p>
if($module=='user' AND $act=='input')
{
$blok=$_POST['blok'];
$lantai=$_POST['lantai'];
$no_kamar=$_POST['no_kamar'];
$nama_domitory=$blok.'-'.$lantai.'-'.$no_kamar;
$isi_penghuni=$_POST['isi_penghuni'];
$biaya_sewa=$_POST['biaya_sewa'];
//untun menginsert data dormitory kedalam mysql
mysql_query("insert into t_dormitory (blok,lantai,no_kamar,nama_dormitory,isi_penghuni,biaya_sewa)values('$blok','$lantai','$no_kamar','$nama_domitory','$isi_penghuni','$biaya_sewa')");
echo "<script>alert('Selamat anda telah berhasil menyimpan data dormitory')</script>";
echo"<script>document.location.href=\"tampil_dormitori.php\";</script>";
//header('location: tampil_perusahaan.php');
}
$nama = 'test.txt';
if(!file_exists($nama)){
echo "<p>file $nama belum ada</p>";
$fp=fopen("$nama","w");
fputs($fp,'isi1');
fclose($fp);
echo "<p>file $nama berhasil dibuat</p>";
} else {
$fp=fopen("$nama","w");
fputs($fp,'isi2');
fclose($fp);
echo "<p>file $nama berhasil dibuat</p>";
}
<form action="form.php" method="post">
nama :<input type="text" name="nama"/>
kelas :<input type="text" name="kelas"/>
<input type="submit" name="submit" value="submit"/>
</form>
<?php
if(isset($_POST['nama']) && isset($_POST['kelas'])){
$nama = $_POST['nama'];
$kelas = $_POST['kelas'];
mysql_connect("localhost","root","");
mysql_select_db("validasiform");
$kirim = mysql_query("insert into form(nama, kelas) values('$nama','$kelas')");
if($kirim) echo "tersimpan di database";
}
?>