Hi I am new to PHP JSON
My URL
http://xxxx.in/event-view.html?event_id=8
My php code (json-eventview.php)
include "db.php";
$data = array();
$id = $_GET['event_id'];
$q=mysqli_query($con,"select * from `ca_events` where ca_events.id=$id ");
while ($row=mysqli_fetch_object($q)){
$data[]=$row;
}
echo json_encode($data);
and Javascript (get Json) used in above url.
$(document).ready(function() {
var url = "http://localhost/php/json-eventview.php";
$.getJSON(url, function(result) {
console.log(result);
$.each(result, function(i, field) {
var id = field.id;
var general_id = field.general_id;
var name = field.name;
var description = field.description;
var agenda = field.agenda;
var date = field.date;
var time = field.time;
$(".navbar-brand span").append(" " + name + " ");
});
});
});
the above gives an empty space.
If, I remove $id = $_GET['event_id']; and WHERE in php file I get the entire table as result.
I need the column values of that particular id in url. can anyone help or give other ideas and examples to get the values based on id from url.