MySQL Database Php

/* You can put this in other file and just include it */
function OpenDb($hostname,$uid,$pwd,$dbname){
$link = @mysql_pconnect($hostname,$uid,$pwd);
if($link && mysql_select_db($dbname)){
return($link);
}
else{
return(FALSE);
}
}
?>
function QueryIntoArray($query){
settype($retval,"array");
$result= mysql_query($query);
if(!$result){
print "Query Failed";
}
for($i=0;$i for($j=0;$j $retval[$i][mysql_field_name($result,$j)] = mysql_result
($result,$i,mysql_field_name($result,$j));
}//end inner loop
}//end outer loop
return $retval;
}//end function
?>



PHP Array Test


OpenDb("myhost","myuid","mypwd","mydatabase") or die("Failed Opening Database");
settype($myresult,"array");
$query = "SELECT * FROM mytable";
$myresult = QueryIntoArray($query);
for($i=0;$i print $myresult[$i]["MyField1"];
print $myresult[$i]["MyField2"];
}
?>