Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Basic-PHP MySQL Code
<?php
$host = "localhost";
$username = "root";
$password = "123";
$db_name = "test";
$db=mysql_connect($host, $username, $password) or die('Could not connect');
mysql_select_db($db_name, $db) or die('no db');
$sth = mysql_query("SELECT * FROM sample s");
$rows = array();
while($r = mysql_fetch_assoc($sth)) {
$rows[] = $r;
}
echo json_encode($rows);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.