Here is my script for loading a table and displaying it in a HTML table.
$fields = $this->db->list_fields($tableName);
$fieldData = $this->db->field_data($tableName);
$this->db->from($tableName);
$this->db->order_by($fields[0], "asc");
$query = $this->db->get(); 
$table = $query->result();
$columnsQ = $this->db->query("select count(column_name) from information_schema.columns where table_name = '".$tableName."'");
$columns = $columnsQ->row();
foreach($table as $row) {
    echo "\t<tr class='value'>\n";
    $colNr = 1;
    foreach ($row as $tdVal) {
        $colNr0 = $colNr-1;
        $valType = $fieldData[$colNr0]->type;
        $isForeign; // how to get info?
        if($colNr==1) {
            echo "\t\t<td data-valType='$valType' class='id'>$tdVal</td>\n"; }
        else {
            echo "\t\t<td data-isForeign='$isForeign' data-valType='$valType' data-colNr='$colNr'>$tdVal</td>\n"; }
        $colNr++;
    }
} 
</table>"; 
What query should be under $isForeign to get info about whether the loaded value is a foreign key or not?
 
     
    