I suggest working with this tutorial so you understand the basics of database functionality
http://www.phpfreaks.com/tutorials/142/0.php
$dbhost = 'localhost';
$dbuser = 'your_user';
$dbpass = 'user_password';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db('your_database');
$sql="SELECT name FROM ".$table_name."WHERE gender='male'";
$retval = mysql_query($sql, $conn );
if (! $retval ) {
print_r($sql);
die('Could not get data: ' . mysql_error());
}
if ($row = mysql_fetch_array($retval, MYSQL_ASSOC)) {
echo "<h1>{$row['gender']}</h1> ";
}
I haven't checked the above code but it should work.