01.
<?php
require
(
'Connections/book.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.
$maxRows_search
= 10;
35.
$pageNum_search
= 0;
36.
if
(isset(
$_GET
[
'pageNum_search'
])) {
37.
$pageNum_search
=
$_GET
[
'pageNum_search'
];
38.
}
39.
$startRow_search
=
$pageNum_search
*
$maxRows_search
;
40.
41.
$colname_search
=
"-1"
;
42.
if
(isset(
$_POST
[
'key'
])) {
43.
$colname_search
=
$_POST
[
'key'
];
44.
}
45.
mysql_select_db(
$database_book
,
$book
);
46.
$query_search
= sprintf(
"SELECT * FROM book_data WHERE book_name_en LIKE %s ORDER BY book_name_en ASC"
, GetSQLValueString(
"%"
.
$colname_search
.
"%"
,
"text"
));
47.
$query_limit_search
= sprintf(
"%s LIMIT %d, %d"
,
$query_search
,
$startRow_search
,
$maxRows_search
);
48.
$search
= mysql_query(
$query_limit_search
,
$book
)
or
die
(mysql_error());
49.
$row_search
= mysql_fetch_assoc(
$search
);
50.
51.
if
(isset(
$_GET
[
'totalRows_search'
])) {
52.
$totalRows_search
=
$_GET
[
'totalRows_search'
];
53.
}
else
{
54.
$all_search
= mysql_query(
$query_search
);
55.
$totalRows_search
= mysql_num_rows(
$all_search
);
56.
}
57.
$totalPages_search
=
ceil
(
$totalRows_search
/
$maxRows_search
)-1;
58.
?>
59.
<table width=
"200"
border=
"0.5"
>
60.
<tr>
61.
<td>ID</td>
62.
<td>EN</td>
63.
<td>TH</td>
64.
<td>Country</td>
65.
</tr>
66.
<?php
do
{ ?>
67.
<tr>
68.
<td><?php
echo
$row_search
[
'book_id'
]; ?></td>
69.
<td><?php
echo
$row_search
[
'book_name_en'
]; ?></td>
70.
<td><?php
echo
$row_search
[
'book_name_th'
]; ?></td>
71.
<td><?php
echo
$row_search
[
'country'
]; ?></td>
72.
</tr>
73.
<?php }
while
(
$row_search
= mysql_fetch_assoc(
$search
)); ?>
74.
</table>
75.
<?php
76.
mysql_free_result(
$search
);
77.
?>