<?PHP mysql_query("SELECT * FROM example"); ?>
Let's talk about fundamentals :)
PHP is a language that, in this case, runs on your web server. It produces the web page that people see, and all of that PHP code is already completely done by the time the page makes it to the user. It runs on the server, and the server only: not the web browser.
json_encode to produce the format and something like jQuery's
$.getJSON to fetch and decode that data.
All of the different languages we have to use on the web can make things a bit tricky. It might be worth trying to get a better understanding of how the web works before embarking on big projects… but I wish you the best of luck!
PHP = server side.
Note, you should be using just
eval() is being called internally.
echo json_encode($result_array) on the php side.