001.
<?php
002.
$HOST_NAME
=
"localhost"
;
003.
$DB_NAME
=
"test"
;
004.
$CHAR_SET
=
"charset=utf8"
;
005.
$USERNAME
=
"root"
;
006.
$PASSWORD
=
""
;
007.
$connect
=
new
PDO(
'mysql:host='
.
$HOST_NAME
.
';dbname='
.
$DB_NAME
.
';'
.
$CHAR_SET
,
$USERNAME
,
$PASSWORD
);
008.
?>
009.
<?php
010.
ini_set
(
'display_errors'
, 1);
011.
error_reporting
(~0);
012.
013.
$strKeyword
= null;
014.
015.
if
(isset(
$_POST
[
"txtKeyword"
]))
016.
{
017.
$strKeyword
=
$_POST
[
"txtKeyword"
];
018.
}
019.
?>
020.
<html>
021.
<head>
022.
<script>
023.
function
gohome(){
024.
025.
document.location.href=
'index.php'
;
026.
}
027.
028.
</script>
029.
<title>ตรวจสอบย้อนหลัง</title>
033.
</head>
034.
<body>
035.
<div
class
=
"container"
>
036.
<br>
037.
<h2 align=
"center"
>กรุณาใส่ชื่อสินค้า</h2>
038.
<br>
039.
<form name=
"frmSearch"
method=
"post"
action=
"<?php echo $_SERVER['SCRIPT_NAME'];?>"
>
040.
<div
class
=
"table-repsonsive"
>
041.
<div align=
"center"
>
042.
<input name=
"txtKeyword"
type=
"text"
id=
"txtKeyword"
value=
"<?php echo $strKeyword;?>"
>
043.
<input type=
"submit"
name=
"submit"
value=
"ยืนยัน"
/>
044.
<input type=
"button"
value=
"กลับหน้าหลัก"
name=
"home"
onclick=
"gohome()"
>
045.
</div>
046.
</div>
047.
</form>
048.
<?php
049.
050.
$sql
=
"SELECT * FROM tbl_order_items WHERE item_name LIKE '%"
.
$strKeyword
.
"%' "
;
051.
052.
$stmt
=
$connect
->prepare(
$sql
);
053.
$stmt
->execute();
054.
055.
?>
056.
<br>
057.
<form name=
""
method=
"post"
>
058.
<table
class
=
"table table-bordered"
>
059.
<tr>
060.
<th> <div align=
"center"
>วันที่ </div></th>
061.
<th> <div align=
"center"
>ชื่อสินค้า </div></th>
062.
<th> <div align=
"center"
>ซื้อ </div></th>
063.
<th> <div align=
"center"
>ใช้ไป </div></th>
064.
<th> <div align=
"center"
>หน่วย </div></th>
065.
</tr>
066.
<?php
067.
while
(
$result
=
$stmt
->fetch( PDO::FETCH_ASSOC ))
068.
{
069.
?>
070.
<tr>
071.
<td align=
"center"
><?php
echo
$result
[
"item_date"
];?></td>
072.
<td align=
"center"
><?php
echo
$result
[
"item_name"
];?></td>
073.
<td align=
"center"
><?php
echo
$result
[
"item_bought"
];?></td>
074.
<td align=
"center"
><input type=
"text"
name=
"item_used[]"
class
=
"form-control item_used"
size=
"1"
/></td>
075.
<td align=
"center"
><?php
echo
$result
[
"item_unit"
];?></td>
076.
</tr>
077.
<?php
078.
}
079.
?>
080.
</table>
081.
<div align=
"center"
>
082.
<input type=
"submit"
name=
"submit1"
value=
"ตกลง"
/>
083.
</div>
084.
</form>
085.
<?php
086.
$connect
= null;
087.
?>
088.
</body>
089.
</html>
090.
<style>
091.
input[type=button] {
092.
color: white;
093.
padding: 6px 12px;
094.
border-radius: 4px;
095.
cursor: pointer;
096.
background-color: #FF6633;
097.
border: 1px solid #FF6666;
098.
}
099.
100.
input[type=button]:hover {
101.
background-color: #FF3300;
102.
}
103.
104.
input[type=button1] {
105.
color: white;
106.
padding: 6px 12px;
107.
border-radius: 4px;
108.
cursor: pointer;
109.
background-color: #FF6633;
110.
border: 1px solid #FF6666;
111.
}
112.
113.
input[type=button1]:hover {
114.
background-color: #FF3300;
115.
}
116.
117.
input[type=submit] {
118.
color: white;
119.
padding: 6px 12px;
120.
border-radius: 4px;
121.
cursor: pointer;
122.
background-color: #FF6633;
123.
border: 1px solid #FF6666;
124.
}
125.
126.
input[type=submit]:hover {
127.
background-color: #FF3300;
128.
}
129.
130.
</style>