mysql_connect('localhost', 'root', ''); mysql_select_db('sampleDB'); $strSQL = 'SELECT * FROM tbAmenities LIMIT 10'; $Result = mysql_query($strSQL); $Response = array(); $Posts = array(); while($row=mysql_fetch_array($Result)) { $id = $row['id']; $amenityname = $row['amenityname']; $amenity[] = array('id'=> $id, 'amenity'=> $amenityname); } $Response['posts'] = $amenity; $fp = fopen('results.json', 'w'); fwrite($fp, json_encode($Response)); fclose($fp);
You must be logged in to post a comment.