01.
<?php
02.
include
'connect.php'
;
03.
04.
try {
05.
$_POST
[
'barcode'
] = 30006000046301;
06.
$barcode
= trim(
$_POST
[
'barcode'
]);
07.
08.
$column
=
$db
->prepare(
'SELECT * FROM tbl_material WHERE barcode = :barcode '
);
09.
$column
->bindParam(
':barcode'
,
$barcode
, PDO::PARAM_STR);
10.
$column
->execute();
11.
$Colcount
=
$column
->columnCount();
12.
13.
14.
$resultArray
=
array
();
15.
16.
while
(
$row
=
$column
->fetch(PDO::FETCH_ASSOC))
17.
{
18.
$arrCol
=
array
();
19.
for
(
$i
=0;
$i
<
$Colcount
;
$i
++)
20.
{
21.
$arrCol
[
$column
->columnCount(
$i
)] =
$row
[
$i
];
22.
}
23.
array_push
(
$resultArray
,
$arrCol
);
24.
}
25.
26.
$db
= null;
27.
28.
echo
json_encode(
$resultArray
);
29.
}
30.
31.
catch (PDOException
$e
) {
32.
echo
'ERROR: '
.
$e
->getMessage();
33.
}
34.
?>