Table of Contents
MySQL Access with PHP
This is a rough outline of the series of commands necessary to connect, query and display rows in a table.
Connect
$my_link = mysql_connect('mysql.aero.und.edu', 'caylan', 'password-goes-here')
or die('Could not connect: ' . mysql_error());
Select Database
mysql_select_db('caylan') or die('Could not select database');
Query
$query = 'select * from notes';
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
Display Results
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
$id = $line[id];
$date = $line[date];
$content = $line[content];
echo "ID: $id, DATE: $date, CONTENT: $content<br>";
}