generic DB to Fast Template routine

wxdqz

New Member
I'm trying to read data from a MsSQL table and assign it to an array for output to a template. I'd like to be able to do it without necessarily knowing in advance the field names.
Tried using mysql_list_fields with no success - I can't even get a print out of the field names, let alone assign them to anything. Here's the code fragment so far...

$strQuery = "SELECT * FROM $tablename WHERE id=$id";
$result = mysql_query("$strQuery");
$resultArray = mysql_fetch_array("$result");

$dbh = mysql_connect("localhost", $username, $password);
$listFields = mysql_list_fields($dbname,$tablename,$dbh);

while($row = mysql_fetch_row($listFields)){
$tpl->assign($row[0], $resultArray[$row[0]]);
}

Any suggestions? Please no 'Um, read the manual' type responses - I have done.
Cheers.
 
Back
Top