Skatecrazy1 Posted November 10, 2006 Share Posted November 10, 2006 well I know this is probably very easily looked up, but I'm short on time;is there any way to call the names of all the fields in a table into an array?thanks. Link to comment https://forums.phpfreaks.com/topic/26776-fetching-column-names/ Share on other sites More sharing options...
reaper7861 Posted November 10, 2006 Share Posted November 10, 2006 [code]$c_sql="Select * from table where row ='$row'"; $res = @mysql_query($c_sql); $r = @mysql_fetch_array($res);[/code]actually i just re-read your post and think im missunderstanding you or your asking for the column names themselves or the data inside them? Link to comment https://forums.phpfreaks.com/topic/26776-fetching-column-names/#findComment-122452 Share on other sites More sharing options...
Monkeymatt Posted November 10, 2006 Share Posted November 10, 2006 Here is a function from a class I have that will return field names in an array.[code]function get_rows($table) { $result=mysql_query("DESCRIBE `".$table."`"); if (!$result) { echo mysql_errno().": ".mysql_error(); } $return=array(); while (($array=mysql_fetch_array($result)) !== false) { $return[]=$array['Field']; } return $return;}[/code]Monkeymatt Link to comment https://forums.phpfreaks.com/topic/26776-fetching-column-names/#findComment-122455 Share on other sites More sharing options...
reaper7861 Posted November 10, 2006 Share Posted November 10, 2006 Ah yes sorry about that matt is on it already ::) Link to comment https://forums.phpfreaks.com/topic/26776-fetching-column-names/#findComment-122457 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.