<?php
/* do the connection info */
$result = mysql_query($query);
if(!$result) {
//The query didn't work properly
} elseif($row = mysql_fetch_row($result)) {
//We have at least one row, but we'll do a do/while so that we can fetch another until we run out
do {
//for each row, put the actions here.
} while($row = mysql_fetch_row($result));
} else {
//The query was valid and executed, but we have no rows, known as an "Empty ResultSet"
//this happens when the WHERE clause of the query makes it so no rows match, or you use
//update/insert/delete which all return nothing.
echo "No rows matched the query.";
}