Welcome Guest, Not a member yet? Register   Sign In
Selecting some of the fields in a table in order you want.
#1

[eluser]cPage[/eluser]
Put this code in your model...

Code:
function select_fields($string = NULL)
{
  if($string !== NULL)
  {
   $q = $this->db->query('SELECT '.$string.' FROM '.$this->table);
  }
  else
  {
   $q = $this->db->query('SELECT * FROM '.$this->table);
  }
  return $q->list_fields();
}

In your controller...
Code:
$this->data['fields'] = $this->client_model->select_fields('client,email');

In your view...
Code:
<table>
&lt;?php
echo'<tr>';
foreach($fields as $field)
{
  echo '<th>'.$field.'</th>';
}
echo'</tr>';
...




Theme © iAndrew 2016 - Forum software by © MyBB