001.
<?php
error_reporting
(0); ?>
002.
<!doctype html>
003.
<html>
004.
<head>
005.
<meta charset=
"utf-8"
>
006.
<title>ค้นหา <?php
echo
$_GET
[
'txtKeyword'
] ?></title>
007.
<?php
include
(
"connect.php"
);?>
008.
</head>
009.
<link rel=
"stylesheet"
type=
"text/css"
href=
"css/bootstrap.min.css"
>
010.
<script src=
"js/jquery-3.1.1.min.js"
></script>
011.
<script src=
"js/bootstrap.min.js"
></script>
012.
<script type=
"text/javascript"
src=
"../src/jquery.jqplot.js"
></script>
013.
<script type=
"text/javascript"
src=
"../src/plugins/jqplot.pieRenderer.js"
></script>
014.
<script type=
"text/javascript"
src=
"../src/plugins/jqplot.donutRenderer.js"
></script>
015.
<link rel=
"stylesheet"
type=
"text/css"
href=
"../src/jquery.jqplot.css"
/>
016.
<meta name=
"viewport"
content=
"width=device-width, initial-scale=1"
>
017.
<body>
018.
<!-- ตัดคำที่ค้นหา -->
019.
<div
class
=
"container-fluid"
style=
"background-color: #f2f2f2"
>
020.
<form name=
"formSearch"
action=
"showdata.php"
method=
"get"
>
021.
<div
class
=
"input-group"
style=
"width: 40%;margin-top: 2%;margin-left: 5%;margin-bottom: 2%"
>
022.
<input type=
"text"
class
=
"form-control input-lg"
name=
"txtKeyword"
id=
"txtKeyword"
size=
"10"
value=
"<?php echo $_GET['txtKeyword'] ?>"
>
023.
<div
class
=
"input-group-btn"
>
024.
<button
class
=
"btn btn-lg"
type=
"submit"
><i
class
=
"glyphicon glyphicon-search"
></i></button>
025.
</div>
026.
</div>
027.
<!--<button type=
"submit"
class
=
"btn-lg btn-info"
><span
class
=
"glyphicon glyphicon-search"
></span> ค้นหา </button> -->
028.
</form>
029.
</div>
030.
<?php
031.
032.
$time_start
= microtime(true);
033.
$text_to_segment
= trim(
$_GET
[
'txtKeyword'
]);
034.
035.
include
(dirname(
__FILE__
) . DIRECTORY_SEPARATOR .
'THSplitLib/segment.php'
);
036.
$segment
=
new
Segment();
037.
$result
=
$segment
->get_segment_array(
$text_to_segment
);
038.
039.
040.
function
convert(
$size
) {
041.
$unit
=
array
(
'b'
,
'kb'
,
'mb'
,
'gb'
,
'tb'
,
'pb'
);
042.
return
@
round
(
$size
/ pow(1024, (
$i
=
floor
(log(
$size
, 1024)))), 2) .
' '
.
$unit
[
$i
];
043.
}
044.
$time_end
= microtime(true);
045.
$time
=
$time_end
-
$time_start
;
046.
047.
048.
049.
050.
051.
052.
053.
054.
055.
056.
?>
057.
<!--จบการตัดคำ-->
058.
<?php
059.
if
(
$result
!=
""
){
060.
$difresult
=
array
(
"หาก"
,
"ไว้"
,
"แห่ง"
,
"ไป"
,
"ได้"
,
"โดย"
,
"แล้ว"
,
"และ"
,
"แรก"
,
"แบบ"
,
"แต่"
,
"เอง"
,
"เห็น"
,
"เลย"
,
"เริ่ม"
,
"เรา"
,
"เมื่อ"
,
"เพื่อ"
,
"เพราะ"
,
"เป็นการ"
,
"เป็น"
,"เปิดเผย
061.
","
เนื่องจาก
","
เดียวกัน
","
เดียว
","
เช่น
","
เฉพาะ
","
เคย
","
เข้า
","
เขา
","
อีก
","
อาจ
","
อะไร
","
ออก
","
อย่าง
","
อยู่
","
อยาก
","
หลาย
","
หลังจาก
062.
","
หลัง
","
หรือ
","
หนึ่ง
","
ส่วน
","
ส่ง
","
");
063.
$result
=
array_diff
(
$result
,
$difresult
);
064.
sort(
$result
);
065.
$iCount
=
count
(
$result
);
066.
$tempdrop
=
"DELETE FROM temp"
;
067.
mysqli_query(
$con
,
$tempdrop
);
068.
069.
$sql
=
"SELECT * from project where name_project like '%"
;
070.
$temp
="INSERT INTO temp (id,student_temp,project_temp,name_temp,branch_temp,professor_temp,years_temp)
071.
SELECT id,student_id,name_project,name_student,branch_student,professor,years from project WHERE name_student like '%";
072.
for
(
$i
= 0 ;
$i
<
$iCount
;
$i
++) {
073.
if
(
$iCount
== 1){
074.
$sql
=
$sql
.
$result
[
$i
].
"%'"
;
075.
$temp
=
$temp
.
$result
[
$i
].
"%'"
;
076.
}
077.
else
if
(
$iCount
> 1){
078.
$sql
=
$sql
.
$result
[
$i
].
"%'"
;
079.
$sql
=
$sql
.
"OR name_project like '% OR name_student like '%"
;
080.
$temp
=
$temp
.
$result
[
$i
].
"%'"
;
081.
$temp
=
$temp
.
"OR name_project like '% OR name_student like '%"
;
082.
}
083.
}
084.
if
(
$iCount
==
$iCount
){
085.
if
(
$iCount
!=1){
086.
$sql
=
substr
(
$sql
,0,-23);
087.
$temp
=
substr
(
$temp
,0,-23);
088.
}
089.
}
090.
$query
= mysqli_query(
$con
,
$sql
);
091.
$querytemp
=mysqli_query(
$con
,
$temp
);
092.
while
(
$data
= mysqli_fetch_array(
$query
)) {
093.
$dataid
=
$data
[
"id"
];
094.
$x
=0;
095.
for
(
$i
=0;
$i
<=
$iCount
;
$i
++){
096.
if
(
strstr
(
$data
[
"name_project"
],
$result
[
$i
])){
097.
$x
++;
098.
099.
}
100.
}
101.
}
102.
$sqltemp
=
"SELECT * from temp Order By id_temp DESC"
;
103.
$tmp
= mysqli_query(
$con
,
$sqltemp
); ?>
104.
<div
class
=
"container-fluid"
>
105.
<?
echo
'<b>คุณค้นหาคำว่า: </b>'
.
$text_to_segment
.
'<br/><br/><br/>'
; ?>
106.
<div
class
=
"row"
>
107.
<div
class
=
"col-sm-10"
style=
"margin-left: 7%"
>
108.
<table
class
=
"table"
>
109.
<tr>
110.
<th>รหัสนักศึกษา</th>
111.
<th>ชื่อโครงงาน</th>
112.
<th>ชื่อนักศึกษา</th>
113.
<th>สาขาที่เรียน</th>
114.
<th>อาจารย์ที่ปรึกษา</th>
115.
<th>ปีที่จบ</th>
116.
</tr>
117.
<?php
while
(
$datatemp
= mysqli_fetch_assoc(
$tmp
)) { ?>
118.
119.
<tr>
120.
<td><?php
echo
$datatemp
[
'student_temp'
];?></td>
121.
<td><?php
echo
$datatemp
[
'project_temp'
];?></td>
122.
<td><?php
echo
$datatemp
[
'name_temp'
];?></td>
123.
<td><?php
echo
$datatemp
[
'branch_temp'
];?></td>
124.
<td><?php
echo
$datatemp
[
'professor_temp'
];?></td>
125.
<td><?php
echo
$datatemp
[
'years_temp'
];?></td>
126.
</tr>
127.
</div>
128.
<div
class
=
"col-sm-1"
style=
"text-align: center;"
>
129.
130.
</div>
131.
</div>
132.
</div>
133.
</div>
134.
<?php } }?>
135.
</div>
136.
</div>
137.
</div>
138.
</body>
139.
</html>