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? Quote Link to comment 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. Quote Link to comment 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/>"; } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.