Fetch types This is not the only way to fetch the results. Using mysql_fetch_array, PHP can place the results into an array in one step. It takes a result as its first parameter, and the way to bind the results as an optional second parameter. If MYSQL_ASSOC is specified, the results are indexed in an array based on their column names in the query. If MYSQL_NUM is specified, then the number starting at zero accesses the results. The default value, MYSQL_BOTH, returns a result array with both types. The mysql_fetch_ assoc is an alternative to supplying the MYSQL_ASSOC argument.
If you rewrote the code above to use mysql_fetch_array with an associative indexed array, it would look like this:
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo $row[title]. '<br />';
}
Closing the Connection As a rule of thumb, you always want to close a connection to a database when you're done using it. Closing a database with mysql_close will tell PHP and MySQL that you no longer will be using the connection, and will free any resources and memory allocated to it.
mysql_close($connection)