01.
<?php
require_once
(
'Connections/db_rice.php'
); ?>
02.
<?php
03.
if
(!function_exists(
"GetSQLValueString"
)) {
04.
function
GetSQLValueString(
$theValue
,
$theType
,
$theDefinedValue
=
""
,
$theNotDefinedValue
=
""
)
05.
{
06.
if
(PHP_VERSION < 6) {
07.
$theValue
= get_magic_quotes_gpc() ?
stripslashes
(
$theValue
) :
$theValue
;
08.
}
09.
10.
$theValue
= function_exists(
"mysql_real_escape_string"
) ? mysql_real_escape_string(
$theValue
) : mysql_escape_string(
$theValue
);
11.
12.
switch
(
$theType
) {
13.
case
"text"
:
14.
$theValue
= (
$theValue
!=
""
) ?
"'"
.
$theValue
.
"'"
:
"NULL"
;
15.
break
;
16.
case
"long"
:
17.
case
"int"
:
18.
$theValue
= (
$theValue
!=
""
) ?
intval
(
$theValue
) :
"NULL"
;
19.
break
;
20.
case
"double"
:
21.
$theValue
= (
$theValue
!=
""
) ? doubleval(
$theValue
) :
"NULL"
;
22.
break
;
23.
case
"date"
:
24.
$theValue
= (
$theValue
!=
""
) ?
"'"
.
$theValue
.
"'"
:
"NULL"
;
25.
break
;
26.
case
"defined"
:
27.
$theValue
= (
$theValue
!=
""
) ?
$theDefinedValue
:
$theNotDefinedValue
;
28.
break
;
29.
}
30.
return
$theValue
;
31.
}
32.
}
33.
34.
$colname_Recordset1
=
"-1"
;
35.
if
(isset(
$_POST
[
'txtProduct'
])) {
36.
$colname_Recordset1
=
$_POST
[
'txtProduct'
];
37.
}
38.
mysql_select_db(
$database_db_rice
,
$db_rice
);
39.
$query_Recordset1
= sprintf(
"SELECT * FROM v_productedit WHERE ProductId LIKE %s"
, GetSQLValueString(
"%"
.
$colname_Recordset1
.
"%"
,
"text"
));
40.
$Recordset1
= mysql_query(
$query_Recordset1
,
$db_rice
)
or
die
(mysql_error());
41.
$row_Recordset1
= mysql_fetch_assoc(
$Recordset1
);
42.
$totalRows_Recordset1
= mysql_num_rows(
$Recordset1
);
43.
?>
46.
<head>
47.
<meta http-equiv=
"Content-Type"
content=
"text/html; charset=utf-8"
/>
48.
<link rel=
"stylesheet"
type=
"text/css"
href=
"templates/main.css"
/>
49.
<title>Rice Mart</title>
50.
</head>
51.
<body>
52.
<div
class
=
"container"
>
53.
<?php
require_once
(
"templates/header.inc.php"
)?>
54.
<?php
require_once
(
"templates/sidenav5.inc.php"
)?>
55.
<form id=
"form1"
name=
"form1"
method=
"post"
action=
""
>
56.
<div
class
=
"content"
>
57.
<h1>ค้นหาข้อมูลสินค้า</h1>
58.
<p>
59.
<label
for
=
"txtProduct"
>ค้นหา</label>
60.
<input type=
"text"
name=
"txtProduct"
id=
"txtProduct"
/>
61.
<input type=
"submit"
name=
"btnProduct"
id=
"btnProduct"
value=
"ค้นหา"
/>
62.
</p>
63.
<table border=
"1"
align=
"center"
>
64.
<tr>
65.
<td>ชื่อสินค้า</td>
66.
<td>ชื่อพันธุ์ข้าว</td>
67.
<td>ราคา</td>
68.
<td>รูปภาพ</td>
69.
<td>แก้ไข</td>
70.
<td>ลบ</td>
71.
</tr>
72.
<?php
do
{ ?>
73.
<tr>
74.
<td><?php
echo
$row_Recordset1
[
'ProductName'
]; ?></td>
75.
<td><?php
echo
$row_Recordset1
[
'RicESeedDesc'
]; ?></td>
76.
<td><?php
echo
$row_Recordset1
[
'price'
]; ?> บาท</td>
77.
<td><img src =
"/DW-DBrice/InsertData/img-products/<?php echo $row_Recordset1['Productimg']; ?>"
alt=
""
width=
"100"
height=
"100"
/></td>
78.
<td><a href=
"UpdateProduct.php?ProductId=<?php echo $row_Recordset1['ProductId']; ?>"
>แก้ไข</a></td>
79.
<td><a href=
"deleteProduct.php?ProductId=<?php echo $row_Recordset1['ProductId']; ?>"
>ลบ</a></td>
80.
</tr>
81.
<?php }
while
(
$row_Recordset1
= mysql_fetch_assoc(
$Recordset1
)); ?>
82.
</table>
83.
</div>
84.
</form>
85.
<?php
require_once
(
"templates/footer.inc.php"
)?>
86.
</div>
87.
</body>
88.
</html>
89.
<?php
90.
mysql_free_result(
$Recordset1
);
91.
?>