Hello I was wondering if this is possible?
$results = $stmt->fetchAll();
$recent_posts = array();
foreach ($results as $row){
$post = array(
'username' => $row['username'],
'steam' => $row['steam'],
'skill' => $row['skill'],
'description' => $row['description'],
'date' => $row['date'],
);
array_push($recent_posts, $post);
}
return json_encode($recent_posts);
If this is possible how exactly do I access it in jquery? $
('#order_by').on('change', function(){
$.ajax({
type: "POST",
url: "sort_skill_be.php",
data: { skill: this.value },
error: function (qXHR, textStatus, errorThrown) {
console.log(errorThrown);
//alert(errorThrown);
},
success: function (result) {
alert(result[0].skill); // CAN I ACCESS IT LIKE THIS?
}
});
});
This is what I have so far, but I keep getting weird errors. When I added datatype:json
I keep getting problems. So I feel I am handling this incorrectly, Thank you for the help!