01.
<html>
02.
<meta http-equiv=
"Content-Language"
content=
"th"
>
03.
<meta http-equiv=
"content-Type"
content=
"text/html; charset=tis-620"
>
04.
<meta http-equiv=
"content-Type"
content=
"text/html; charset=window-874"
>
05.
<meta http-equiv=Content-Type content=
"text/html; charset=utf-8"
>
06.
07.
<head>
08.
</head>
09.
<body>
10.
<?php
11.
require_once
'Classes/PHPExcel.php'
;
12.
include
'Classes/PHPExcel/IOFactory.php'
;
13.
$inputFileMAJOR
=
"1.xls"
;
14.
$inputFileType
= PHPExcel_IOFactory::identify(
$inputFileMAJOR
);
15.
$objReader
= PHPExcel_IOFactory::createReader(
$inputFileType
);
16.
$objReader
->setReadDataOnly(true);
17.
$objPHPExcel
=
$objReader
->load(
$inputFileMAJOR
);
18.
19.
$objWorksheet
=
$objPHPExcel
->setActiveSheetIndex(0);
20.
$highestRow
=
$objWorksheet
->getHighestRow();
21.
$highestColumn
=
$objWorksheet
->getHighestColumn();
22.
23.
$headingsArray
=
$objWorksheet
->rangeToArray(
'A1:'
.
$highestColumn
.
'1'
,null, true, true, true);
24.
$headingsArray
=
$headingsArray
[1];
25.
26.
$r
= -1;
27.
$namedDataArray
=
array
();
28.
for
(
$row
= 2;
$row
<=
$highestRow
; ++
$row
) {
29.
$dataRow
=
$objWorksheet
->rangeToArray(
'A'
.
$row
.
':'
.
$highestColumn
.
$row
,null, true, true, true);
30.
if
((isset(
$dataRow
[
$row
][
'A'
])) && (
$dataRow
[
$row
][
'A'
] >
''
)) {
31.
++
$r
;
32.
foreach
(
$headingsArray
as
$columnKey
=>
$columnHeading
) {
33.
$namedDataArray
[
$r
][
$columnHeading
] =
$dataRow
[
$row
][
$columnKey
];
34.
}
35.
}
36.
}
37.
foreach
(
$namedDataArray
as
$result
) {
38.
$ii
=
$result
[
"uname"
].
" "
;
39.
}
40.
41.
$arrlength
=
count
(
$ii
);
42.
for
(
$x
= 0;
$x
<
$arrlength
;
$x
++) {
43.
$ii
[
$x
];
44.
if
(
$ii
!=
""
)
45.
{
46.
$objConnect
= odbc_connect(
"trans"
,
""
,
""
)
or
die
(
"Error Connect to Database"
);
47.
$strSQL
=
"SELECT * FROM dbo_PERSON_EDU WHERE (uname LIKE '%"
.
$ii
[
$x
].
"%' )"
;
48.
$objExec
= odbc_exec(
$objConnect
,
$strSQL
)
or
die
(
"Error Execute ["
.
$strSQL
.
"]"
);
49.
while
(
$objResult
= odbc_fetch_array(
$objExec
))
50.
{
51.
echo
$objResult
[
"id"
].
" "
.
$objResult
[
"uname"
].
"<br>"
;
52.
}}
53.
odbc_close(
$objConnect
);
54.
}
55.
?>
56.
</body>
57.
</html>