How to create simple webservice in php using JSON
Type the following code in your notepad save it with .php extension.
and now run it from your browser.
<?php
$con=mysql_connect("localhost","root","");
if(!$con)
{
die("Error");
}
mysql_select_db("webservice",$con);
/*Data Fetch Query [Select Query to fetch data from any table]*/
$sql="Select * from webservice";
$result=mysql_query($sql);
$post=array();
while($row=mysql_fetch_assoc($result))
{
$post[]=$row;
}
print_r(json_encode($post));
?>
Comments
Post a Comment