I am trying to fetch data from my database, but when I visit MYWEBPAGE.com/service.php?id=2
(yes, there is an article with that id), then it just writes:
[true]
, instead for showing me the objects as json.
Here is my code:
<?php
include('includingThis.php');
$idFromUrl = addslashes($_GET[id]);
$resultArray = array();
$tempArray = array();
if ($stmtTitle = $con->prepare("SELECT * FROM artikler WHERE id=?")) {
/* bind parameters for markers */
$stmtTitle->bind_param("i", $idFromUrl);
$stmtTitle->execute();
// Loop through each row in the result set
while($row = $stmtTitle->fetch()) {
// Add each row into our results array
$tempArray = $row;
array_push($resultArray, $tempArray);
}
// Finally, encode the array to JSON and output the results
echo json_encode($resultArray);
}
// Close connections
mysqli_close($con);
?>
</div>