Skip to content

jnorthard/mysql-to-json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

mysql-to-json

Write a MySQL Database to JSON using PHP

<?php
//Collect the data  
  $results = mysql_query("SELECT * FROM table");  
  $rows = array();
  while($r = mysql_fetch_assoc($results)) {
    $rows[] = $r;
  }
//Write the data to results.json
  $fp = fopen('results.json', 'w');
  fwrite($fp, json_encode($rows));
  fclose($fp);
?>

About

Write a MySQL Database to JSON using PHP

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published