Use a php file which simply outputs json data.  E.g.


<?php

//Get some data from a table
$my_array = array();
$result1 = @mysql_query("SELECT field1, field2 FROM table1 ORDER BY field1");
while ($row = @mysql_fetch_array($result1))
{
   $my_array[] = $row;
}

//Add it and some other data to an array
$data = array(
  "results" => array(
    "my_field1" => "abcd",
		"my_array" => "my_array",
    "my_manual_array" => array(
      "item" =>
      array(
        array(
          "item_field1" => "123456",
          "item_field2" => "Hello 1"
        ),
        array(
          "item_field1" => "7890",
          "item_field2" => "Hello 2"
        )
      )
    )
  )
);

//Output it as json
echo json_encode($data);
?>

 

Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

Your email address will not be published.