I'm not sure why this is confusing, but here's an example.
<?php
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
$result = mysql_query('create database foo');
if (!$result)
die('Invalid query: ' . mysql_error());
else echo 'You dunnit.';
mysql_close($link);
?>
After the DB is created you can go about the process of creating tables and inserting data.