Misi bli,
Mau tanya ane bikin menu edit / update berdasarkan pencarian id number. Ketika kita ketik id number itu, akan muncul datanya. Ketika saya mau validasi jam berdasarkan tanggal yang di update user, jam di combo box tidak mau mem-validasi jam di tanggal sekian sehingga ada kemungkinan jam-nya sama.
Saya sudah coba buat tp tdk bisa jalan.
Ini menu edit.php
<?php
include "koneksi.php";
$no = $_GET['ticket'];
$tampil = "SELECT * FROM event WHERE no='$no'";
$check = mysql_query($tampil,$con) or die("Gagal");
$c = mysql_fetch_array($check);
?>
<a href="search.php">Back</a>
<br>
<html>
<head>
<title>Date</title>
<script type="text/javascript" src="jquery-1.5.1.min.js"></script>
<script type="text/javascript" src="jquery-ui-1.8.11.custom.min.js"></script>
<link rel="stylesheet" type="text/css" href="jquery-ui-1.8.11.custom.css">
<script type="text/javascript">
$(document).ready(function()
{
$("#date").datepicker(
{
dateFormat: "dd-mm-yy",
changeMonth: true,
changeYear: true,
yearRange: "-0:+100"
});
});
</script>
</head>
<form name="form" method="POST" action="">
<table>
<tr>
<td>Date</td>
<td> : </td>
<td>
<input type="text" id="date" name="date" onchange='this.form.submit()' <?php if(isset($_POST['date'])) { echo "value='$_POST[date]'";} else { echo "value=$c[date]"; }?> >
</td>
</tr>
<tr>
<td>Time Before</td>
<td> : </td>
<td>
<select name="bef">
<option value="<?php echo $c['event'] ;?>" > <?php echo $c['event'] ;?> </option>
</select>
</td>
</tr>
<tr>
<td>Time</td>
<td> : </td>
<td>
<select name="time" onchange='this.form.submit()'>
<option value="<?php echo $c['event'] ;?>" > <?php echo $c['event'] ;?> </option>
<?php
if(isset($c['date']))
{
$cek = mysql_query("SELECT * FROM event WHERE date=$c[date]");
$jum = mysql_num_rows($cek);
$no = 0;
$a = '';
if($jum > 0)
{
while($abc = mysql_fetch_array($cek))
{
$no = $no + 1;
if($no !== $jum) { $a .="'".$abc['event']."',"; }
if($no == $jum) { $a.="'".$abc['event']."'"; }
}
$jam = mysql_query("SELECT * FROM clock WHERE clock NOT IN ($a) ORDER BY id ASC");
while($b = mysql_fetch_array($jam))
{
if($b['clock']==$_POST['time'])
{
echo "<option selected>$b[clock]</option>";
}
else
{
echo "<option>$b[clock]</option>";
}
}
}else
{
$jam = mysql_query("SELECT * FROM clock ORDER BY id ASC");
while($b = mysql_fetch_array($jam))
{
if($b['clock']==$_POST['time'])
{
echo "<option selected>$b[clock]</option>";
}
else
{
echo "<option>$b[clock]</option>";
}
}
}
}else
{
$jam = mysql_query("SELECT * FROM clock ORDER BY id ASC");
while($b = mysql_fetch_array($jam))
{
if($b['clock']==$_POST['time'])
{
echo "<option selected>$b[clock]</option>";
}
else
{
echo "<option>$b[clock]</option>";
}
}
}
?>
</select>
</td>
</tr>
</table>
</form>
Tapi kalau kita masukin data baru, validasi pada combo box jam jalan gan, sehingga tidak ada kemungkinan jam-nya sama pada tanggal yang sama.
Ini menu tambah_baru.php
<?php
include "koneksi.php";
?>
<head>
<title>Date</title>
<script type="text/javascript" src="jquery-1.5.1.min.js"></script>
<script type="text/javascript" src="jquery-ui-1.8.11.custom.min.js"></script>
<link rel="stylesheet" type="text/css" href="jquery-ui-1.8.11.custom.css">
<script type="text/javascript">
$(document).ready(function()
{
$("#tanggal").datepicker(
{
dateFormat: "dd-mm-yy",
changeMonth: true,
changeYear: true,
yearRange: "-0:+100"
});
});
</script>
</head>
<form name="form" method="POST">
<table>
<tr>
<td>Tanggal</td>
<td> : </td>
<td><input name="tanggal" id="tanggal" type="text" onchange='this.form.submit()' <?php if(isset($_POST['tanggal'])) { echo "value='$_POST[tanggal]'";}?>/>
</td>
</tr>
<tr>
<td>Time</td>
<td> : </td>
<td>
<select name="time" onchange='this.form.submit()'>
<?php
if(isset($_POST['tanggal']) and isset($_POST['time']))
{
$cek = mysql_query("SELECT * FROM event WHERE date='$_POST[tanggal]'");
$jum = mysql_num_rows($cek);
$no = 0;
$a = '';
if($jum > 0)
{
while($abc = mysql_fetch_array($cek))
{
$no = $no + 1;
if($no !== $jum) { $a .="'".$abc['event']."',"; }
if($no == $jum) { $a.="'".$abc['event']."'"; }
}
$jam = mysql_query("SELECT * FROM clock WHERE clock NOT IN ($a) ORDER BY id ASC");
while($b = mysql_fetch_array($jam))
{
if($b['clock']==$_POST['time'])
{
echo "<option selected>$b[clock]</option>";
}
else
{
echo "<option>$b[clock]</option>";
}
}
}else
{
$jam = mysql_query("SELECT * FROM clock ORDER BY id ASC");
while($b = mysql_fetch_array($jam))
{
if($b['clock']==$_POST['time'])
{
echo "<option selected>$b[clock]</option>";
}
else
{
echo "<option>$b[clock]</option>";
}
}
}
}else
{
$jam = mysql_query("SELECT * FROM clock ORDER BY id ASC");
while($b = mysql_fetch_array($jam))
{
if($b['clock']==$_POST['time'])
{
echo "<option selected>$b[clock]</option>";
}
else
{
echo "<option>$b[clock]</option>";
}
}
}
?>
</select>
</td>
</tr>
</table>
<br><br><center><input type="submit" value="Send" name="Send"></center>
</form>
Mohon petunjuk ...
Thanks