router- AddRoot search getlist function base data _GET data username u

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
$router->AddRoot("search","getlist",
function($base)
{
//$data = $_GET['data'];
$username = "user";
$sql = "SELECT * FROM `Products` INNER JOIN `User#".$username."` ON `Products`.Pr_id = `User#".$username."`.Us_itemid";
$result = $base->query($sql);
$data = array();
$i = 0;
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
$data[$i] = array("id"=>$row["Pr_id"], "name"=>$row["Pr_name"], "num"=>$row["Pr_num"], "price"=>$row["Pr_price"],
"src"=>$row["Pr_imgsrc"], "itemid"=>$row["Us_id"]);
$i++;
}
$action = true;
$message = "Data found";
} else {
$action = false;
$message = "Data not found";
}
echo json_encode (
array(
"info"=>array("action"=>$action, "message"=>$message),
"data"=>$data
)
);
});