ok here is some code i use.
// Connects To Datebase With Error Function
$conn = mysql_connect("username", "password", "localhost");
if ($conn == false){
echo mysql_errno().": ".mysql_error()."<BR>";
exit;
}
mysql_select_db("test_database");
// Gets Table And Does Query Functions
$query = "select * from test_exp";
$result = mysql_query($query);
$numOfRows = mysql_num_rows ($result);
for ($i = 0; $i < $numOfRows; $i++)
// Turns A Certain Row Into A Variable
$variable = mysql_result ($result, $i, "RowName");
// Outputs Row Info
echo $variable;
i hope that give you some kind of a idea on how to do it.