01.
<?php
require_once
(
'Connections/dbcon.php'
); ?>
02.
<?php
03.
if
(!function_exists(
"GetSQLValueString"
)) {
04.
function
GetSQLValueString(
$theValue
,
$theType
,
$theDefinedValue
=
""
,
$theNotDefinedValue
=
""
)
05.
{
06.
$theValue
= get_magic_quotes_gpc() ?
stripslashes
(
$theValue
) :
$theValue
;
07.
08.
$theValue
= function_exists(
"mysql_real_escape_string"
) ? mysql_real_escape_string(
$theValue
) : mysql_escape_string(
$theValue
);
09.
10.
switch
(
$theType
) {
11.
case
"text"
:
12.
$theValue
= (
$theValue
!=
""
) ?
"'"
.
$theValue
.
"'"
:
"NULL"
;
13.
break
;
14.
case
"long"
:
15.
case
"int"
:
16.
$theValue
= (
$theValue
!=
""
) ?
intval
(
$theValue
) :
"NULL"
;
17.
break
;
18.
case
"double"
:
19.
$theValue
= (
$theValue
!=
""
) ?
"'"
. doubleval(
$theValue
) .
"'"
:
"NULL"
;
20.
break
;
21.
case
"date"
:
22.
$theValue
= (
$theValue
!=
""
) ?
"'"
.
$theValue
.
"'"
:
"NULL"
;
23.
break
;
24.
case
"defined"
:
25.
$theValue
= (
$theValue
!=
""
) ?
$theDefinedValue
:
$theNotDefinedValue
;
26.
break
;
27.
}
28.
return
$theValue
;
29.
}
30.
}
31.
32.
$maxRows_rsResult
= 5;
33.
$pageNum_rsResult
= 0;
34.
if
(isset(
$_GET
[
'pageNum_rsResult'
])) {
35.
$pageNum_rsResult
=
$_GET
[
'pageNum_rsResult'
];
36.
}
37.
$startRow_rsResult
=
$pageNum_rsResult
*
$maxRows_rsResult
;
38.
39.
$colname_rsResult
=
"-1"
;
40.
if
(isset(
$_GET
[
' txtName '
])) {
41.
$colname_rsResult
=
$_GET
[
' txtName '
];
42.
}
43.
mysql_select_db(
$database_dbcon
,
$dbcon
);
44.
$query_rsResult
= sprintf(
"SELECT * FROM rawmaterial WHERE name_m LIKE %s ORDER BY name_m ASC"
, GetSQLValueString(
"%"
.
$colname_rsResult
.
"%"
,
"text"
));
45.
$query_limit_rsResult
= sprintf(
"%s LIMIT %d, %d"
,
$query_rsResult
,
$startRow_rsResult
,
$maxRows_rsResult
);
46.
$rsResult
= mysql_query(
$query_limit_rsResult
,
$dbcon
)
or
die
(mysql_error());
47.
$row_rsResult
= mysql_fetch_assoc(
$rsResult
);
48.
49.
if
(isset(
$_GET
[
'totalRows_rsResult'
])) {
50.
$totalRows_rsResult
=
$_GET
[
'totalRows_rsResult'
];
51.
}
else
{
52.
$all_rsResult
= mysql_query(
$query_rsResult
);
53.
$totalRows_rsResult
= mysql_num_rows(
$all_rsResult
);
54.
}
55.
$totalPages_rsResult
=
ceil
(
$totalRows_rsResult
/
$maxRows_rsResult
)-1;
58.
<head>
59.
<meta http-equiv=
"Content-Type"
content=
"text/html; charset=windows-874"
/>
60.
<title>Untitled Document</title>
61.
<style type=
"text/css"
>
62.
<!--
63.
.style4 { font-family:
"TX Melittin"
;
64.
font-size: 16px;
65.
}
66.
-->
67.
</style>
68.
</head>
69.
70.
<body>
71.
<table width=
"464"
border=
"1"
>
72.
<tr>
73.
<td width=
"72"
>เลข</td>
74.
<td width=
"376"
>ชื่อ</td>
75.
</tr>
76.
<?php
do
{ ?>
77.
<tr>
78.
<td><?php
echo
$row_rsResult
[
'id'
]; ?></td>
79.
<td><?php
echo
$row_rsResult
[
'name_m'
]; ?></td>
80.
</tr>
81.
<?php }
while
(
$row_rsResult
= mysql_fetch_assoc(
$rsResult
)); ?>
82.
</table>
83.
</body>
84.
</html>
85.
<?php
86.
mysql_free_result(
$rsResult
);
87.
?>