rondog Posted September 24, 2010 Share Posted September 24, 2010 hey guys im getting my column names with this query: $query = mysql_query("SELECT column_name FROM information_schema.columns WHERE table_name = 'cam_systems'"); I then have an array: $fields = array( "cfg_change_date" => "Configuration Change Date", "system_name" => "System Name", "system_manf" => "System Manufacturer", "system_model_no" => "System Model Number", "system_serial_no" => "System Serial Number", "system_board_part_no" => "System Board Part Number", "system_board_serial_no" => "System Board Serial Number", "asset_tag" => "Asset Tag", "sla_code" => "SLA Code", "category" => "Category", "os_version" => "OS Version", "os_upgraded" => "OS Upgraded", "bios_version" => "BIOS Version", "bios_upgraded" => "BIOS Upgraded", "ilom_version" => "ILOM Version", "ilom_ip" => "ILOM IP Address", "ilom_updated" => "ILOM Updated", "rack_id" => "Rack ID", "rack_location_id" => "Rack Location ID", "tech_id" => "Tech ID", "warranty" => "Warranty" ); I need to display these field names now, but rather than the actual column name, I've created an array with column name and then the name I want to actual display. How can I do that? Is their a better way I should be doing this? Link to comment https://forums.phpfreaks.com/topic/214254-displaying-colum-names/ Share on other sites More sharing options...
ShibSta Posted September 24, 2010 Share Posted September 24, 2010 Look at the array_keys() function in PHP. Link to comment https://forums.phpfreaks.com/topic/214254-displaying-colum-names/#findComment-1114877 Share on other sites More sharing options...
rondog Posted September 24, 2010 Author Share Posted September 24, 2010 I figured it out without that: while ($row = mysql_fetch_array($query)) { echo $fields[$row['column_name']] . "<br/>"; } Link to comment https://forums.phpfreaks.com/topic/214254-displaying-colum-names/#findComment-1114890 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.