diff --git a/application/controllers/Forms.php b/application/controllers/Forms.php
index f8120ea..6c53cf7 100644
--- a/application/controllers/Forms.php
+++ b/application/controllers/Forms.php
@@ -290,6 +290,9 @@ class Forms extends CI_Controller
$user_id = $this->session->userdata('user_id');
$data['responses'] = $this->Form_model->get_responses_by_form($form_id);
$data['form'] = $this->Form_model->get_form($form_id);
+ $responses = $this->Form_model->get_responses_by_form($form_id);
+
+
$this->load->view('templates/header');
$this->load->view('forms/form_responses', $data);
diff --git a/application/models/Form_model.php b/application/models/Form_model.php
index 9a32dcd..3b2d826 100644
--- a/application/models/Form_model.php
+++ b/application/models/Form_model.php
@@ -138,7 +138,7 @@ class Form_model extends CI_Model {
$response_data = [
'form_id' => $form_id,
'user_id' => $this->session->userdata('user_id'), // Set user_id if applicable
- 'created_at' => date('Y-m-d H:i:s'),
+ 'submitted_at' => date('Y-m-d H:i:s'),
];
$this->db->insert('responses', $response_data);
$response_id = $this->db->insert_id();
@@ -176,13 +176,16 @@ class Form_model extends CI_Model {
$query = $this->db->get('forms');
return $query->result();
}
-
public function get_responses_by_form($form_id) {
- $this->db->where('form_id', $form_id);
- $query = $this->db->get('responses');
+ $this->db->select('responses.user_id, users.username, responses.submitted_at,responses.response_id');
+ $this->db->from('responses');
+ $this->db->join('users', 'responses.user_id = users.user_id');
+ $this->db->where('responses.form_id', $form_id);
+ $query = $this->db->get();
return $query->result();
}
+
public function get_response($response_id) {
$this->db->where('response_id', $response_id);
$query = $this->db->get('responses');
diff --git a/application/views/forms/form_responses.php b/application/views/forms/form_responses.php
index 156cc43..480fb92 100644
--- a/application/views/forms/form_responses.php
+++ b/application/views/forms/form_responses.php
@@ -7,6 +7,7 @@
@@ -14,8 +15,9 @@
Response ID
+ User Name
Submitted At