Created
July 31, 2013 20:32
-
-
Save rileypaulsen/6125875 to your computer and use it in GitHub Desktop.
generate JSON with rows grouped by a specific column
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
mysql_connect("localhost", "root", ""); | |
mysql_select_db("coins"); | |
$result = mysql_query("select * from coins"); | |
$list = array(); | |
while ($r = mysql_fetch_object($result)) { | |
$list[$r->society][] = $r->ID; | |
} | |
print_r(json_encode($list)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment