001.
<?php
require_once
(
'Connections/cn.php'
); ?>
002.
<!doctype html>
003.
<html lang=
"en"
>
004.
<head>
005.
<!-- Required meta tags -->
006.
<meta charset=
"utf-8"
>
007.
<meta name=
"viewport"
content=
"width=device-width, initial-scale=1, shrink-to-fit=no"
>
008.
009.
<!-- Bootstrap CSS -->
011.
<title>Home</title>
012.
</head>
013.
<body>
014.
<div
class
=
"container"
>
015.
<div
class
=
"row"
>
016.
<div
class
=
"col-md-12"
>
017.
<h2 p align=
"center"
>ค้นหาข้อมูลลูกค้า
018.
</p></h2></center><hr />
019.
</div></div></div>
020.
<div
class
=
"container"
>
021.
<div
class
=
"row"
>
022.
<div
class
=
"col-md-12"
>
023.
024.
<form id=
"form1"
name=
"form1"
method=
"post"
action=
""
class
=
"form-horizontal"
>
025.
<div
class
=
"col-sm-0"
>
026.
<input name=
"txtKey"
type=
"text"
id=
"txtKey"
placeholder=
"กรอกข้อมูลที่จะค้นหา"
size=
"40"
value=
"<?php isset($_POST["
txtKey
"]) ?>"
>
027.
<input type=
"submit"
name=
"button"
id=
"button"
value=
"ค้นหา"
class
=
"btn btn-warning"
>
028.
029.
<select name=
"tbSelect"
id=
"tbSelect"
>
030.
<option value=
"0"
<?php
if
(isset(
$_POST
[
"tbSelect"
]) ==
"0"
) {}?>>--Select--</option>
031.
<option value=
"id"
<?php
if
(isset(
$_POST
[
"tbSelect"
]) ==
"id"
) {}?>> รหัสสมาชิก</option>
032.
<option value=
"F_name"
<?php
if
(isset(
$_POST
[
"tbSelect"
]) ==
"F_name"
) {}?>> ชื่อ</option>
033.
<option value=
"L_name"
<?php
if
(isset(
$_POST
[
"tbSelect"
]) ==
"L_name"
) {}?>> นามสกุล</option>
034.
<option value=
"city"
<?php
if
(isset(
$_POST
[
"tbSelect"
]) ==
"city"
) {}?>> จังหวัด</option>
035.
<option value=
"post"
<?php
if
(isset(
$_POST
[
"tbSelect"
]) ==
"post"
) {}?>>รหัสไปรษณ</option>
036.
<option value=
"email"
<?php
if
(isset(
$_POST
[
"tbSelect"
]) ==
"email"
) {}?>> email</option>
037.
<option value=
"username"
<?php
if
(isset(
$_POST
[
"tbSelect"
]) ==
"username"
) {}?>> Username</option>
038.
</select>
039.
</label>
040.
</form>
041.
</div>
042.
<br>
043.
<?php
044.
045.
$sql
=
"select * from member where 1 "
;
046.
047.
if
(isset(
$_POST
[
"tbSelect"
]) !=
""
and
isset(
$_POST
[
"txtKey"
]) !=
""
){
048.
$sql
.=
" AND ("
.
$_POST
[
"tbSelect"
] .
" LIKE '%"
.
$_POST
[
"txtKey"
] .
"%') "
;
049.
}
050.
051.
052.
$objQuery
= mysql_query(
$sql
)
or
die
(
"ไม่พบข้อมูลที่ค้นหาได้ ["
.
$sql
.
"]"
);
053.
054.
$num
= mysql_num_rows(
$objQuery
);
055.
if
(
$num
==0)
056.
{
057.
echo
"<script>"
;
058.
echo
"alert('ไม่พบข้อมูลที่คุณค้นหา!');"
;
059.
echo
"window.location='#testabababbababaababababab.php';"
;
060.
echo
"</script>"
;
061.
}
else
062.
063.
?>
064.
065.
<table height=
"150"
border=
"1"
>
066.
<tr>
067.
<td width=
"80"
height=
"61"
align=
"center"
bgcolor=
"#99FF66"
>รหัสสมาชิก</td>
068.
<td width=
"80"
height=
"61"
align=
"center"
bgcolor=
"#99FF66"
>ชื่อ</td>
069.
<td width=
"110"
height=
"61"
align=
"center"
bgcolor=
"#99FF66"
>นามสกุล</td>
070.
<td width=
"420"
height=
"61"
align=
"center"
bgcolor=
"#99FF66"
>ที่อยู่</td>
071.
<td width=
"80"
height=
"61"
align=
"center"
bgcolor=
"#99FF66"
>จังหวัด</td>
072.
<td width=
"80"
height=
"61"
align=
"center"
bgcolor=
"#99FF66"
>รหัสไปรษณี</td>
073.
<td width=
"80"
height=
"61"
align=
"center"
bgcolor=
"#99FF66"
>E-mail</td>
074.
<td width=
"80"
height=
"61"
align=
"center"
bgcolor=
"#99FF66"
>เบอร์โทรศัพท์</td>
075.
<td width=
"80"
height=
"61"
align=
"center"
bgcolor=
"#99FF66"
>Username</td>
076.
</tr>
077.
<?php
078.
while
(
$data
= mysql_fetch_array(
$objQuery
)){
079.
?>
080.
<tr>
081.
<td width=
"80"
height=
"61"
align=
"center"
><?php
echo
$data
[
"id"
]; ?></td>
082.
<td align=
"center"
><?php
echo
$data
[
"F_name"
]; ?></td>
083.
<td align=
"center"
><?php
echo
$data
[
"L_name"
]; ?></td>
084.
<td align=
"left"
><?php
echo
$data
[
"address"
]; ?></td>
085.
<td align=
"center"
><?php
echo
$data
[
"city"
]; ?></td>
086.
<td align=
"center"
><?php
echo
$data
[
"post"
]; ?></td>
087.
<td align=
"center"
><?php
echo
$data
[
"email"
]; ?></td>
088.
<td width=
"120"
height=
"61"
align=
"center"
><?php
echo
$data
[
"tel"
]; ?></td>
089.
<td align=
"center"
><?php
echo
$data
[
"username"
]; ?></td>
090.
</tr>
091.
<?php
092.
}
093.
094.
?>
095.
</table>
096.
<br>
097.
</center></font>
098.
<center><p><a href=
"member2.php"
class
=
"btn btn-info btn-lg "
role=
"button"
aria-pressed=
"true"
>กลับสู่หน้าหลัก</a></p></center>
099.
</p>
100.
</div>
101.
</div>
102.
</div>
103.
<?php
104.
mysql_close();
105.
?>
106.
</body>
107.
</html>