Friday, August 12, 2011

Create Json file using php from mysql database data

<?php
$link = mysql_pconnect("localhost", "root", "siva123") or die("Could not connect");
mysql_select_db("jacksiva") or die("Could not select database");

$arr = array();
$rs = mysql_query("SELECT * FROM ss_emp");

while($obj = mysql_fetch_array($rs)) {
$arr[] = $obj;

}
$json = '{"sample":'.json_encode($arr).'}';
echo $json;
?>

No comments:

Post a Comment