PHP/MySQL Query Example
A basic MySQL query using PHP with commenting marked with //.
// SQL statement that will be sent to the MySQL database server.
$szQry = “SELECT column1, column2 FROM foo”;
// MySQL database login credentilas; host (127.0.0.1), username and password.
$szDBConn = mysql_connect(”host”,”username”,”password”);
// Select database using the login credentials provided above.
mysql_select_db(”database_name”, $szDBConn);
// Send SQL statement to database.
$saResults = mysql_query($szQry, $szDBConn);
// Fetch results retured back from the SQL statement.
$obResults = mysql_fetch_row($saResults);

