65,624 views
28 votes
28 votes
HOW DO I CONNECT TO MY mysql server on my computer locally using php and also how to run it on the browser

User Dinorah
by
2.7k points

1 Answer

11 votes
11 votes

Answer:

<?php

$mysqli = new mysqli("127.0.0.1:3307", "myUser", "myPass", "databasename");

$query = "SELECT * FROM users ORDER BY name";

if($result = $mysqli->query($query))

{

echo '<ul>';

while ($obj = $result->fetch_object())

{

echo '<li>'.$obj->name.'</li>';

}

$result->free();

echo '</ul>';

}

else

{

die("nothing found");

}

$mysqli->Close();

?>

Step-by-step explanation:

This should get you started.

User GIGAMOLE
by
2.9k points