A basic MySQL query using PHP with commenting marked with //.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | // 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); // Close database connection mysql_close($szDBConn); |