PHP is a server-side scripting language. It's not like HTML. HTML is a mark-up language, PHP is more like C, C++ and C# than it is HTML, XML, XHTML etc. PHP is used to interface with databases, sessions, cookies, and the server to authenticate against a database, do simple loops, browse a directory, or simply display dynamic content.
MySQL is your database. It is nothing more than tables inside of databases. It's main purpose is to store information. PHP is the scripting language that interfaces with the database. PHP tells mySQL the queries to run, and then deals with the results mySQL gives it.
A simple PHP and mySQL page would look like:
<?php // Start the PHP code area
// <-- A comment marker, can be either : // or # or for multi-lines: /* ... */
// Let's make some variables
$dbhost = 'localhost'; // Assigns the string "localhost" to variable $dbhost
$dbuser = 'root';
$dbpass = 'pass';
$dbdb = 'test';
// Let's connect to a mySQL server:
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('MySQL Error: '.mysql_error());
/*
What's happening is that we're calling the function mysql_connect() with three parameters: host, user, and pass. If we can't get a good connection, then our script is killed with the "or die()" statement. Inside the die() function we want to output what the error was so we do that with concatenation of a string "MySQL Error: ' and the result of a function: mysql_error()
If a valid resource is returned, $conn will hold the resource identifier.
*/
$query = "SELECT * FROM `test`"; // A simple query
// Execute the query:
$result = mysql_query($query);
// Loop through results
while($row = mysql_fetch_array($result)) {
for($i=0; $i<count($row); $i++) {
echo $row[$i].'<br>';
}
}
/*
Here we take our result set, and loop through it. For each row returned, we get an array with the mysql_fetch_array() function. Then inside the while() loop we iterate over the $row array and echo out all the values with the for() loop.
*/
// Close the mySQL connection
mysql_close($conn);
/* End the PHP code area */ ?>
That's a basic idea of a script. If you want to get into PHP and mySQL, I suggest you google for some PHP and mySQL tutorials.