 |
|
มี 2 ตารางครับฟิวด้านในเหมือนกันทุกอย่างครับ
total1,total2
tid,tcode,tprice,tpro,tunit,tqty,tdate,tname,tsave,tupdate,tstatus
Code (SQL)
CREATE TABLE `total` (
`tid` int(11) NOT NULL,
`tcode` varchar(13) NOT NULL,
`tprice` float NOT NULL,
`tpro` float NOT NULL,
`tunit` int(11) NOT NULL,
`tqty` float NOT NULL,
`tdate` date NOT NULL,
`tname` varchar(50) NOT NULL,
`tsave` varchar(50) NOT NULL,
`tupdate` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`tstatus` varchar(10) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE `total2` (
`tid` int(11) NOT NULL,
`tcode` varchar(13) NOT NULL,
`tprice` float NOT NULL,
`tpro` float NOT NULL,
`tunit` int(11) NOT NULL,
`tqty` float NOT NULL,
`tdate` date NOT NULL,
`tname` varchar(50) NOT NULL,
`tsave` varchar(50) NOT NULL,
`tupdate` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`tstatus` varchar(10) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
Code (PHP)
<!DOCTYPE html>
<html lang="en"><head>
<meta charset="utf-8">
<form name="frmSearch" method="get" action="<?php echo $_SERVER['SCRIPT_NAME'];?>">
<br/>
<select name="txtKeyword3" type="text" id="txtKeyword3" placeholder="ระบุชื่อห้อง" value="<?php echo $_GET["txtKeyword3"];?>" >
<option value="">-- เลือก --</option>
<option>พนักงาน</option>
<option>ลูกค้า</option>
</select>
<br/>
<input name="txtKeyword" type="text" id="txtKeyword" placeholder="" value="<?php echo $_GET["txtKeyword"];?>" >
<script type="text/javascript">
jQuery('#txtKeyword').datetimepicker({
lang:'th',
timepicker:false,
format:'Y-m-d'
});
</script>
<br/>
<input name="txtKeyword2" type="text" id="txtKeyword2" placeholder="" value="<?php echo $_GET["txtKeyword2"];?>" >
<script type="text/javascript">
jQuery('#txtKeyword2').datetimepicker({
lang:'th',
timepicker:false,
format:'Y-m-d'
});
</script>
<br/>
<button type="submit" id="btnConfirm" > ค้นหา</button>
<button type="reset" > รีเซ็ต</button>
<br/>
</form>
<?php
if($_GET["txtKeyword"] != "" or $_GET["txtKeyword2"] != "" or $_GET["txtKeyword3"] != "")
{
include('condb.ua.php');
$strSQL = "SELECT * FROM total1 union SELECT * FROM total2 WHERE (tdate between '".$_GET["txtKeyword"]."' and '".$_GET["txtKeyword2"]."' and tname LIKE '%".$_GET["txtKeyword3"]."%') ";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
<table width="100%" border="1" align="center">
<tr>
<th height="47" bgcolor="#5DADE2"><div align="center">ชื่อ</div></th>
<th height="47" bgcolor="#5DADE2"><div align="center">วันที่</div></th>
</tr>
<?php
while($objResult = mysql_fetch_array($objQuery))
{
?>
<tr>
<td width="5%"> <?php echo $objResult["tname"];?></td>
<td width="5%"> <?php echo $objResult["tdate"];?></td>
</tr>
<?php
}
?>
</table>
</body>
</html>
Tag : PHP, MySQL
|
ประวัติการแก้ไข 2018-11-27 14:14:59
|
 |
 |
 |
 |
Date :
2018-11-27 14:13:08 |
By :
HLEW |
View :
603 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |