Welcome Guest, Not a member yet? Register   Sign In
Problem creating a 2-D array from table details
#1

[eluser]alwaystyred[/eluser]
Hi, I am trying to create a 2-D array containing details of the tables and the fields within those tables. This is the code in my controller:
Code:
$this->view_data['tables'] = $this->db->list_tables();
foreach ($this->view_data['tables'] as $table) {
$this->view_data['tables']['fields'] = $this->db->list_fields($table);
}

This works fine for the tables, I am able to get all of those in the view, but it only returns the field details of the last table it queries.

The code in the view is:
Code:
foreach ($tables as $table) {
echo '<p class="head">' .$table . '</p>';

echo '<div class="body">';
foreach ($tables['fields'] as $field) {
  echo '&lt;input type="checkbox" name="field" value="' . $table . '.' . $field .'" /&gt;' . $field . '<br />';
}
echo '</div>';
}

Thanks for help in advance, if you need more info, I'm happy to provide


Messages In This Thread
Problem creating a 2-D array from table details - by El Forum - 05-07-2012, 07:01 AM
Problem creating a 2-D array from table details - by El Forum - 05-07-2012, 07:38 AM
Problem creating a 2-D array from table details - by El Forum - 05-07-2012, 06:41 PM



Theme © iAndrew 2016 - Forum software by © MyBB