I am looking to populate an array of all columns that are being viewed in a query lets say
$sql='SELECT a.tutorial_id, a.tutorial_author, b.tutorial_count
FROM tutorials_tbl a, tcount_tbl b
WHERE a.tutorial_author = b.tutorial_author';
function getColoumns($sql) {
$result = mysql_query("SHOW COLUMNS FROM (". $sql."));
if (!$result) {
echo 'Could not run query: ' . mysql_error();
}
$fieldnames=array();
if (mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_assoc($result)) {
$fieldnames[] = $row['Field'];
}
}
return $fieldnames;
}
I cant seem to get it right. Anyone out there who can help me out. Thanks in Advance.