I am new to PHP. I am trying to read MySQL with this PHP code.
....
$sql = "select * from GameMaster where UserId = '".$_POST["UserId"]."'";
$result = mysqli_query($link, $sql);
$rows = array();
$return = array();
while($row = mysqli_fetch_array($result)) {
$rows['UserId'] = $row['UserId'];
$rows['Nick'] = $row['Nick'];
$rows['Items'] = $row['Items'];
$rows['Skills'] = $row['Skills'];
...
$rows['LastUpdate'] = $row['LastUpdate'];
array_push($return, $rows);
}
header("Content-type:application/json");
echo json_encode($return);
Soon after runnning this code, it gets into infinite loop. When I deleted the array_push line, it did not go into infinite loop. So I guess that'd be the problem, but I can't find out why.
Is there something wrong with my code? The MySQL database is in Amazon lightsail.
Please help me. Thanks in advance for any comments.
whilecondition, which has nothing to do witharray_push().$rowto$rows? The array keys are the same, so you can just doarray_push($return, $row);