I created an accounts page wherein I can view all accounts from the database. Each of them has an action button called View More. If I press View More, additional details from the database will be displayed in textboxes. I want to get the ID for each of the row and pass it to the controller in order for it to be viewed. However, I can't seem to make them show in the boxes.
Expected: Image
Current: Image
Controller:
function viewmore()
{
$userid = $this->input->get('userid', TRUE);
$data['view'] = $this->model_accounts->viewmore_user($userid);
$data['main_content'] = 'view_adminviewmore';
$this->load->view('includes/admin_viewmore_template', $data);
}
Model:
public function viewmore_user($userid)
{
$query= $this->db->select('*')->from('accounts')->where('userid', $userid)->get();
return $query->result();
}
View for the Action Button:
<?php foreach($users as $row): ?>
<tr>
<td><?php echo $row->firstname; ?></td>
<td><?php echo $row->lastname; ?></td>
<td><?php echo $row->username; ?></td>
<td><?php echo $row->address; ?></td>
<td class="action-button mobile-important">
<a href="<?php echo base_url() ."admin_accounts/viewmore/?id=". $row->userid ?>"> <button type="button" class="btn btn-custom-3">View More</button></a>
</td>
<?php endforeach; ?>
</tr>
View for displaying the data:
<?php foreach($view as $row): ?>
<br>
<p> First Name </p>
<input class="form-control" id="sel1" type="text" placeholder="" value="<?php echo $row->firstname; ?>">
<br>
<p> Last Name </p>
<input class="form-control" id="sel1" type="text" placeholder="" value="<?php echo $row->lastname; ?>">
<br>
<p> Username </p>
<input class="form-control" id="sel1" type="text" placeholder="" value="<?php echo $row->username; ?>">
<br>
<p> Address </p>
<input class="form-control" id="sel1" type="text" placeholder="" value="<?php echo $row->address; ?>">
<br>
<p> E-mail Address </p>
<input class="form-control" id="sel1" type="email" placeholder="" value="<?php echo $row->email; ?>">
<br>
<p> Contact Number </p>
<input class="form-control" id="sel1" type="text" placeholder="" value="<?php echo $row->contactnum; ?>">
<br>
<?php endforeach; ?>