This is my PHP/JSON script from localhost:
http://www16.zippyshare.com/v/6486125/file.html is the link if you need to download the PHP files to edit them in your answers if you want. (The link to the JSON file is mentioned in large-schedule.js in the file. Instructions on usage provided).
It partially works (as in the file echoes the data).
This is the code:
<?
header('Content-type: application/json; charset=utf-8');
header("access-control-allow-origin: *");
$link = mysql_pconnect("localhost", "test", "test") or die("Could not connect");
mysql_select_db("radiostations") or die("Could not select database");
$arr = array();
$rs = mysql_query("SELECT * FROM radio1r1");
while($obj = mysql_fetch_object($rs)) {
$arr[] = $obj;
}
echo '{"success":true,"error":"","data":{"schedule":['.json_encode($arr).'}';
echo isset($_GET['callback'])
? "{$_GET['callback']}($json)"
: $json;
However, I cannot get the contents of the fields startminutes and endminutes (stored as DATETIME) to display as 01/02/2013 00:00:00 within the JSON, in order to display them as 01/02/\2013 00:00:00
The fields I have are in the SQL file above.
As a PHP/JSON file the code works at a basic level; I can do callbacks well, but is there an easier way to get success true error data to display without manually putting it in?
As for the query string callback, I intend to do it so it has these 4 stations with different results from the MySQL tables:
Radio 1
Anytown FM
Big City FM
so the callback would look like
http://127.0.0.1
/phpradiostation/radioschedule-json.php?callback=?&name=Anytown+FM
or
http://127.0.0.1
/phpradiostation/radioschedule-json.php?callback=?&name=Big+City+FM
I have got it halfway there, with regard to the JSON but it displays a blank page despite there being data in the database!
PHP info: I'm using 5.4.1.0, on MAMP, OS X Mavericks, if that's relevant.
Basically, what I am asking is for help on actually getting it to display the data in the javascript.
Any help is appreciated!