How to open MySQL database and view a table with MySQLi Object in PHP

1 Answer

0 votes
$db = new mysqli("localhost", "username", "password", "databasename");

$sql = "SELECT * FROM a_table";
$result = $db->query($sql);
while ($row = $result->fetch_assoc()) 
    print_r($row); // $row['field']

$result->close();
$db->close();


answered Apr 23, 2014 by avibootz
edited May 20, 2015 by avibootz

Related questions

...