<?php
//This document displays how PHP can interact with MySQL.
$con = mysql_connect(“localhost”,”root”,”") or die(mysql_error());
//the or die() function will throw an error if the connection fails. This can be added to the SQL calls made in this file.
//with WAMP basic settings the above will connect to the Virtualized MySQL Server
$db = mysql_select_db(“MyDB”);
//Without first creating a Database by the name of MyDB in phpmyadmin this will throw an error.
$sql = mysql_query(“SELECT * FROM MyTable”);
//This pulls all the data from the MyTable Table.
while ($row = mysql_fetch_array($sql))
//This will make $row the variable to call the data from the database.
{
echo $row['Col1'];
echo ‘<br/>’;
echo $row['Col2'];
// echoing $row['NameOfColumn']; will echo the results from each cell in the named column.
}
?>