@adan
To display SQL table fields in CodeIgniter, you can use the following query in your controller method:
1 2 3 4 5 6 7 8 9 10 |
public function display_fields() { $this->load->database(); $table_name = 'your_table_name'; $query = $this->db->query("SHOW COLUMNS FROM $table_name"); $fields = $query->result_array(); foreach($fields as $field) { echo $field['Field'] . "<br>"; } } |
In this code snippet, we use the SHOW COLUMNS FROM
SQL query to retrieve the fields of the specified table "your_table_name". We then loop through the result and display each field name using the echo
statement.
Make sure to replace 'your_table_name' with the actual name of your SQL table in the code above.