Hi everyone i am working on a small beginner project currently i am working on displaying two separate table data on a web page in HTML table but i am having some problems with the data. There is a credentials table and an answers table a user first enters its credentials and then presses the button take survay which stores the credentials on to a table and redirects the user to a question page where he picks a multiple choice question and the users choices are saved to a table. all this data then is displayed on web page but when the data is displayed the answers get duplicated fore every user that enter its details. can someone tell me where have i gone wrong ? tnx for your help in advance.
view
<table border="1">
<tr>
<th>Name</th>
<th>Second Name</th>
<th>Phone</th>
<th>Email</th>
<th>Answer</th>
<th>Comment</th>
</tr>
<?php foreach ($query as $row): ?>
<tr>
<td><?php echo $row->name; ?></td>
<td><?php echo $row->second_name; ?></td>
<td><?php echo $row->phone; ?></td>
<td><?php echo $row->email; ?></td>
<td> <?php echo $row->answerA;?>
<?php echo $row->answerB;?>
<?php echo $row->answerC;?></td>
<td><?php echo $row->comment;?><br></td>
</tr>
<?php endforeach; ?>
</table>
controller
function getall(){
$this->load->model('result_model');
$data['query'] = $this->result_model->result_getall();
$this->load->view('result_view', $data);
}
model
function result_getall(){
return $this->db->select('tblanswers.*,credentials.*')
->from('tblanswers, credentials')
->get()
->result_object();
}