database -test
table category
columns-category_id , category
<?php
//connect to mySQL
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
//Select database
mysql_select_db("test",$con);
//query table
$sql=mysql_query("SELECT * FROM category ORDER BY `category`.`category` ASC");
while($row=mysql_fetch_assoc($sql))
$output[]=$row;
print(json_encode($output));
mysql_close($con);
?>
No comments:
Post a Comment