$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
)
);
});