[eluser]Unknown[/eluser]
Hi everyone, I've been doing this for almost a month but I cannot figure it out on how to get the "details" of every row in my table. My table in my view is foreach. And post it in another page. By clicking the link named "Details..." on first page.
for example: ive searched in first page and this is the result:
----------
column1 column1 column3 column4 column5 column6
name desc age num add Details...
name2 desc2 age2 num2 add Details...
When i click the first details... it would go to second page and post name, desc, age, num, add into textbox. same as the second details...
Any help would be greatly appreciated. Thanks.
here are my codes:
my model model.php - this is my code for search data in my database table
Code:
public function search_equip() {
if ($this->input->post('category') == "All")
{
$match = $this->input->post('search');
$array = array('column1' => $match);
$this->db->like($array);
$query = $this->db->get('equip');
return $query->result();
}
elseif ($this->input->post('category') == "Appliance")
{
$match = $this->input->post('search');
$array = array('column1' => $match, 'category' => "Appliance");
$this->db->like($array);
$query = $this->db->get('equip');
return $query->result();
}
elseif ($this->input->post('category') == "Furniture")
{
$match = $this->input->post('search');
$array = array('column1' => $match, 'category' => "Furniture");
$this->db->like($array);
$query = $this->db->get('equip');
return $query->result();
}
elseif ($this->input->post('category') == "Equipment")
{
$match = $this->input->post('search');
$array = array('column1' => $match, 'category' => "Equipment");
$this->db->like($array);
$query = $this->db->get('equip');
return $query->result();
}
}
----------
my controller search.php - my code with set rules
Code:
function search_equipment()
{
//If searchbox is empty
$this->load->helper(array('form', 'url'));
$this->load->library('form_validation');
$this->form_validation->set_rules('search', 'Search', 'required|xss_clean');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('auth/index', 'refresh');
}
else
{
$data['query'] = $this->model->search_equip();
$this->load->view('auth/search_view_equipment', $data);
}
}
----------
my view search_view_equipment.php - this is where i search data and show results with the link every row
Code:
<?php
echo "<table border=1 cellpadding=5>";
echo "<tr>";
echo "<td><b>Column1</b></td>";
echo "<td><b>Column2</b></td>";
echo "<td><b>Column3</b></td>";
echo "<td><b>Column4</b></td>";
echo "<td><b>Column5</b></td>";
echo "<td><b>Column6</b></td>";
echo "</tr>";
foreach($query as $item){
echo "<tr>";
echo "<td>".<?= $item->Column1 ?>."</td>";
echo "<td>".<?= $item->Column2 ?>;."</td>";
echo "<td>".<?= $item->Column3 ?>."</td>";
echo "<td>".<?= $item->Column4 ?>;."</td>";
echo "<td>".<?= $item->Column5 ?>;."</td>";
echo "<td>".anchor("auth/view_equipment_details/".$item->Column6, 'Details...', array('class' => 'detail'))."</td>";
echo "</tr>";
}
echo "</table>";
?>
----------
my second view view_equipment.php - this is where to post the data coming from first page (specific row)
Note: This td's are input, i dunno how to make a code here using input
Code:
<?php
foreach($query as $item){
echo "<tr>";
echo "<td>".<?= $item->Column1 ?>."</td>";
echo "<td>".<?= $item->Column2 ?>;."</td>";
echo "<td>".<?= $item->Column3 ?>."</td>";
echo "<td>".<?= $item->Column4 ?>;."</td>";
echo "<td>".<?= $item->Column5 ?>;."</td>";
echo "<td>".anchor("auth/view_equipment_details/".$item->Column6, 'Details...', array('class' => 'detail'))."</td>";
echo "</tr>";
}
echo "</table>";
?>
----------
Is it possible to get that whole data of that row and show it in another page? Specifically, I'm confused on what am I going to do, because the table is in foreach. I cannot get the value of the specific link in first page, here's my code on getting the value of links in first page but im not succesful:
controller: auth.php
Code:
function view_equipment_details()
{
$data['equipid'] = $this->model->get_equipment_id();
$this->load->view('auth/view_equipment', $data);
}
model: addition in model.php
Code:
public function get_equipment_id() {
$match = $this->input->post(); //This line is where i want to put the specific links ( any links that i click in first page) VALUE or NAME or whatsoever that is EXACTLY THE SAME AS THE ID OF THAT ROW I WILL CLICK to search using (next line): all i need is the value equal to the id of a row in table in database.
$array = array('id' => $match);
$this->db->where($array);
$equipid = $this->db->get('equip');
return $equipid->result();
}
Thank you in advance for any help. Hoping for a feed back.