Skip to content

Instantly share code, notes, and snippets.

@quique123
Created February 19, 2010 15:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save quique123/308802 to your computer and use it in GitHub Desktop.
Save quique123/308802 to your computer and use it in GitHub Desktop.
<?php
include_once("JSON.php");
$json = new Services_JSON();
$link = mysql_pconnect("localhost", "usr", "pwd") or die("Could not connect");
mysql_select_db("dbname") or die("Could not select database");
$query = "SELECT * FROM users";
$result = mysql_query($query);
$arr = array();
$rs = mysql_query("SELECT * FROM users");
while($obj = mysql_fetch_object($rs)) {
$arr[] = $obj;
}
Echo '{"sample":'.$json->encode($arr).'}';
//------------------
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment