CodeIgniter Forums
Check data in template - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Check data in template (/showthread.php?tid=49584)



Check data in template - El Forum - 02-26-2012

[eluser]Unknown[/eluser]
Hi, all !

i have
Code:
$data['table'] = $table[$this->input->post('table')];
$result = $this->db->query("DESCRIBE " . $data['table']);
$data['alias'] = $result->result();
and
Code:
$data = array('table' => $data['table'], 'fields' => $data['alias']);
Ok, push to template...

Code:
$this->template->parse_view('table','site/default/block/table_fields', $data);
$this->template->render();

Then, code in 'table_fields.php'

Code:
{fields}
  <tr>
    <th  class="even" >{Field}</th>
    <td align='center'>{Type}</td>
    &lt;?php
        $key = '{Key}'; // <= HERE
        // How to check $key. Ex:

             if(strstr($key,'PRI') == 0) // <= not work
               echo "Primary key";
        // Always echo "Primary key"
       // My table have 3 fields(id(PRI),user,email)Then, echo 3 line "Primary key". However, i want echo 1 line "Primary key" at id.
        
     ?&gt;
  </tr>
{/fields}

How to check variable $key is what ?