|
|
|
อยากให้ นำค่าวันที่ไปค้นหาค่าเวลาปัจจุบันในฐานข้อมูลครับ |
|
|
|
|
|
|
|
อยากได้โค้ต นำค่าวันที่ที่ได้ ไปเทียบเพื่อนำเวลาปัจจุบันในฐานข้อมูลมาแสดงครับ
ตัวอย่างภาพหน้าเว็บครับ
เมื่อเลือกวันที่แล้ว ให้ ดึงข้อมูลเวลามากกว่าปัจจุบันครับ
Code (PHP)
<tr>
<td class="blue_bg_color"><div align="right"><strong>วันที่ใช้ห้อง : </strong></div></td>
<td class="yellow_bg_color"><input name="startdate" type="text" id="startdate" size="12" > 
<span class="redfont">*</span></td>
</tr>
<tr>
<td class="blue_bg_color"><div align="right"><strong>ช่วงเวลาที่ใช้ : </strong></div></td>
<td class="yellow_bg_color"><select name="starttime" id="starttime">
<option value="0" selected="selected" >เวลา</option>
<?
$sql="select * from meeting_starttime";
$dbquery = mysql_db_query($dbname, $sql);
$num_rows = mysql_num_rows($dbquery);
$i=0;
while ($i < $num_rows)
{
$result = mysql_fetch_array($dbquery);
$time_id=$result[time_id];
$time_name=$result[time_name];
echo"<option value='$time_name'>$time_name</option>";
$i++;
}
?>
</select>
ถึง
<select name="endtime" id="endtime">
<option value="0" selected="selected">เวลา</option>
<?
$sql="select * from meeting_endtime";
$dbquery = mysql_db_query($dbname, $sql);
$num_rows = mysql_num_rows($dbquery);
$i=0;
while ($i < $num_rows)
{
$result = mysql_fetch_array($dbquery);
$time_id=$result[time_id];
$time_name=$result[time_name];
echo"<option value='$time_name'>$time_name</option>";
$i++;
}
?>
</select> <span class="redfont">*</span> </td>
</tr>
Code (SQL)
CREATE TABLE `meeting_starttime` (
`time_id` int(11) NOT NULL auto_increment,
`time_name` varchar(20) default NULL,
PRIMARY KEY (`time_id`)
) ENGINE=MyISAM DEFAULT CHARSET=tis620 AUTO_INCREMENT=12 ;
--
-- Dumping data for table `meeting_starttime`
--
INSERT INTO `meeting_starttime` VALUES (1, '08:00:00');
INSERT INTO `meeting_starttime` VALUES (2, '09:01:00');
INSERT INTO `meeting_starttime` VALUES (3, '10:01:00');
INSERT INTO `meeting_starttime` VALUES (4, '11:01:00');
INSERT INTO `meeting_starttime` VALUES (5, '13:00:00');
INSERT INTO `meeting_starttime` VALUES (6, '14:01:00');
INSERT INTO `meeting_starttime` VALUES (7, '15:01:00');
INSERT INTO `meeting_starttime` VALUES (11, '16:01:00');
Tag : PHP, MySQL, JavaScript
|
|
|
|
|
|
Date :
2015-06-07 14:05:01 |
By :
fad1412 |
View :
878 |
Reply :
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Format ที่ถูกต้องจะต้องเป็น YYYY-MM-DD ครับ
SQL MYSQL DATE_FORMAT
|
|
|
|
|
Date :
2015-06-07 18:47:24 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณพี่ให้คำแนะนำคับ แต่เวลาที่เลือกวันที่แล้ว ถ้าตรงกับวันปัจจุบัน ให้เวลาเริ่มจากปัจจุบัน (ไม่ให้เลือกย้อนหลัง)
กำลังหาแบบ action script รบกวนปรึกษาขอคำแนะนำด้วยครับ
|
|
|
|
|
Date :
2015-06-07 20:00:17 |
By :
fad1412 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ผม drum หน้าเพื่อทดสอบมาครับ อยากให้เลือกวันที่แล้ว ไปดึงข้อมูลเวลาออกมาเลยครับ
Code (PHP)
<? include("inc/connect_db.php"); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<link type="text/css" rel="stylesheet" href="jquery/css/smoothness/jquery-ui-1.7.2.custom.css" />
<style type="text/css">
.ui-tabs{ font-family:tahoma; font-size:14px;}
</style>
<style type="text/css">
.ui-datepicker{ width:190px; font-family:tahoma; font-size:14px; text-align:center;}
</style>
<script src="jquery/js/jquery-1.3.2.min.js"></script>
<script src="jquery/js/jquery-ui-1.7.2.custom.min.js"></script>
<script type="text/javascript">
$(function(){
var dateBefore=null;
$("#startdate").datepicker({
dateFormat: 'dd/mm/yy',
showOn: 'button',
//buttonImage: 'images/calendar.gif',
buttonImageOnly: false,
minDate: 0,
});
});
</script>
</head>
<body>
<?
$sql="select * from meeting_booking where book_id='31' ";
$dbquery=mysql_db_query($dbname, $sql);
while($result=mysql_fetch_array($dbquery))
{
$dept=$result[department];
$subject=$result[subject];
$head=$result;
$num=$result[numpeople];
$startdate=$result[startdate];
$enddate=$result[enddate];
$starttime=$result[starttime];
$endtime=$result[endtime];
$bookname=$result[bookname];
$ref_room_id=$result[room_id];
$comment=$result[comment];
}
list($year, $month, $day) = split('[/.-]', $startdate);
$startdate= "$day/$month/$year";
?>
<form action="" name="form1" method="post">
<table width="95%" border="0" align="center" cellpadding="3" cellspacing="5">
<tr>
<td width="145" class="blue_bg_color"><div align="right">วันที่ใช้ห้อง : </div></td>
<td class="yellow_bg_color"><input name="startdate" type="text" id="startdate" value="<? echo "$startdate"; ?>" size="12" onchange="chkalert3()"/> <span class="redfont">*</span> </td>
</tr>
<tr>
<td class="blue_bg_color"><div align="right">ช่วงเวลาที่ใช้ : </div></td>
<td class="yellow_bg_color">
<select name="starttime" id="starttime">
<?
echo "<script type='text/javascript'>";
echo "function chkalert3() {";
echo "var startdate1 = document.form1.startdate.value;";
$startdate1 = startdate1;
$todaytime = date("H:i:s");
$todaydate = date("d/m/Y");
if ($startdate1 == $todaydate) {
$sql="select * from meeting_starttime where time_name >= '$todaytime'";
$dbquery=mysql_db_query($dbname, $sql);
while($result=mysql_fetch_array($dbquery))
{
$time_id=$result[time_id];
$time_name=$result[time_name];
if($endtime==$time_name)
{
echo "<option value='$time_name' selected>$time_name</option>";
}else {
echo "<option value='$time_name'>$time_name</option>";
}
}
}else{
$sql="select * from meeting_starttime";
$dbquery=mysql_db_query($dbname, $sql);
while($result=mysql_fetch_array($dbquery))
{
$time_id=$result[time_id];
$time_name=$result[time_name];
if($endtime==$time_name)
{
echo "<option value='$time_name' selected>$time_name</option>";
}else
{
echo "<option value='$time_name'>$time_name</option>";
}
}
}
echo "}";
echo "</script>";
?>
</select>
ถึง
<select name="endtime" id="endtime">
<?
$todaytime = date("H:i:s");
$todaydate = date("d/m/Y");
if ($startdate == $todaydate) {
$sql="select * from meeting_endtime where time_name >= '$todaytime'";
$dbquery=mysql_db_query($dbname, $sql);
while($result=mysql_fetch_array($dbquery))
{
$time_id=$result[time_id];
$time_name=$result[time_name];
if($endtime==$time_name)
{
echo "<option value='$time_name' selected>$time_name</option>";
}else {
echo "<option value='$time_name'>$time_name</option>";
}
}
}else{
$sql="select * from meeting_endtime";
$dbquery=mysql_db_query($dbname, $sql);
while($result=mysql_fetch_array($dbquery))
{
$time_id=$result[time_id];
$time_name=$result[time_name];
if($endtime==$time_name)
{
echo "<option value='$time_name' selected>$time_name</option>";
}else
{
echo "<option value='$time_name'>$time_name</option>";
}
}
}
echo "<script type='text/javascript'>";
echo "function chkalert4() {";
echo "var sqlq = '$sql';";
echo "alert(sqlq);";
echo "} </script>";
?>
</select>
<span class="redfont">*</span> </td>
</tr>
<tr>
<td class="blue_bg_color"><div align="right">
<input name="edit" type="hidden" id="edit" value="<? echo $edit_book_id; ?>" />
</div></td>
<td class="yellow_bg_color"><input type="button" name="Button" value="แก้ไขการจอง" onclick="chkform2();"/>
<input type="reset" name="Submit2" value="ยกเลิก" /></td>
</tr>
</table>
</form>
</body>
</html>
[head]Code (SQL)
CREATE TABLE `meeting_starttime` (
`time_id` int(11) NOT NULL auto_increment,
`time_name` varchar(20) default NULL,
PRIMARY KEY (`time_id`)
) ENGINE=MyISAM DEFAULT CHARSET=tis620 AUTO_INCREMENT=15 ;
--
-- Dumping data for table `meeting_starttime`
--
INSERT INTO `meeting_starttime` VALUES (1, '08:00:00');
INSERT INTO `meeting_starttime` VALUES (2, '09:01:00');
INSERT INTO `meeting_starttime` VALUES (3, '10:01:00');
INSERT INTO `meeting_starttime` VALUES (4, '11:01:00');
INSERT INTO `meeting_starttime` VALUES (5, '13:00:00');
INSERT INTO `meeting_starttime` VALUES (6, '14:01:00');
INSERT INTO `meeting_starttime` VALUES (7, '15:01:00');
INSERT INTO `meeting_starttime` VALUES (11, '16:01:00');
CREATE TABLE `meeting_endtime` (
`time_id` int(11) NOT NULL auto_increment,
`time_name` varchar(20) default NULL,
PRIMARY KEY (`time_id`)
) ENGINE=MyISAM DEFAULT CHARSET=tis620 AUTO_INCREMENT=13 ;
--
-- Dumping data for table `meeting_endtime`
--
INSERT INTO `meeting_endtime` VALUES (12, '09:00:00');
INSERT INTO `meeting_endtime` VALUES (2, '10:00:00');
INSERT INTO `meeting_endtime` VALUES (3, '11:00:00');
INSERT INTO `meeting_endtime` VALUES (4, '12:00:00');
INSERT INTO `meeting_endtime` VALUES (5, '14:00:00');
INSERT INTO `meeting_endtime` VALUES (6, '15:00:00');
INSERT INTO `meeting_endtime` VALUES (7, '16:00:00');
INSERT INTO `meeting_endtime` VALUES (11, '17:00:00');
|
|
|
|
|
Date :
2015-06-08 17:33:46 |
By :
fad1412 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|