In PHP 5 using the MySQLi extension : mysqli_connect « MySQL Database « PHP






In PHP 5 using the MySQLi extension

 
<?php

    $mysqli = mysqli_connect("localhost", "root", "","mydatabase", 3306);

    $result = mysqli_query($mysqli, "SELECT * FROM mytable");

    while($row = mysqli_fetch_array($result)) {

        foreach($row as $key => $value) {

            echo "$key = $value</BR>\n";

        }

    }

    mysqli_free_result($result);
    mysqli_close($mysqli);

?>
  
  








Related examples in the same category

1.Discovering Which Extension Is Being Used
2.MySQL Connection Test
3.function mysql_connect() establishes an initial connection with the MySQL server.
4.custom-error-messages.php