/ Published in: PHP

mysql2json.class.php
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<? /** * Filename: mysql2json.class.php * Purpose: Convert mysql resultset data into JSON(http://json.org) format * Author: Adnan Siddiqi <[email protected]> * License: PHP License * Date: Tuesday,June 21, 2006 * */ class mysql2json{ function getJSON($resultSet,$affectedRecords){ $numberRows=0; $i=0; $json=""; //print("Test"); if (!$meta) { }else{ $arrfieldName[$i]=$meta->name; } $i++; } $i=0; $json="{\n\"data\": [\n"; $i++; //print("Ind ".$i."-$affectedRecords<br>"); $json.="{\n"; $json.="\"$arrfieldName[$r]\" : \"$row[$r]\""; $json.=",\n"; }else{ $json.="\n"; } } if($i!=$affectedRecords){ $json.="\n},\n"; }else{ $json.="\n}\n"; } } $json.="]\n};"; return $json; } } ?>
URL: http://www.phpclasses.org/browse/file/14803.html
Comments
