Connection and extracting data from a MySQL database with PHP
The following code example creates a connection to a MySQL database, and displays some fields of a table.
Code:
<?php
$connection = mysql_connect("127.0.0.1", "root", "")
or die("Connection failed: " . mysql_error());
$db = mysql_select_db("crm" , $connection)
or die('Could not select database.');
$result = mysql_query("SELECT * FROM user ORDER BY User");
while($records = mysql_fetch_row($result)) {
echo ($records[1] . "<br />");
}
mysql_close($connection);
?>