Im using ajax to update my data. Ajax calls my function.php where i use a switch to determent which function to run. I save my results in a json object ($resp = new stdClass). But how do i save multiple rows (with multiple columns) into the json object?
function func1($mysqli){
$result = $mysqli->query("select * from order");
///how do i fetch all rows in a loop and save it correctly to my json object?
return json;
}
$resp = new stdClass;
if (isset($_POST["action"])) {
switch($_POST["action"])) {
case "func1":
$resp->data = func1($mysqli);
break;
}
}
echo json_encode($resp);