Mikael Louis Mikael Louis - 3 years ago 174
MySQL Question

CodeIgniter using if to show some table

So i am trying to make a website for collecting data from user and classify the data as 'suspicious' or 'not suspicious'. After i collect and classify the data, i want to show and send to server ONLY 'suspicious' data.

My table has one column called 'note', where the value of the 'note' is 'suspicious' or 'not suspicious'

is it possible to show the part of table that only have 'not suspicious' value in 'note' ? if possible, can you guys give me any idea how ?

Here is my code for showing the data:

Controller:



public function success() {
$dataz['resultss'] = $this->welcome_model->dataz();
$this->load->view('success',$dataz);
}


Model

public function dataz() {
$query = $this->db->get('info');
$results = $query->result();
return $resultss;
}


View

<?php
foreach($resultss as $row) {
echo '<tr>';
echo '<td>'.$row->name.'</td>';
echo '<td>'.$row->note.'</td>';
?>
<td>
</td>
<?php
echo '</tr>';
}
?>


Any help would be appreciated!

Answer Source

You can achieve your objective in many ways.

For 'not suspicious' records, use this,

 $query = $this->db->get_where('info', array('note' => 'not suspicious'));

For 'suspicious' records, use this,

 $query = $this->db->get_where('info', array('note' => 'suspicious'));
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download