Welcome Guest, Not a member yet? Register   Sign In
dropdown populated by database, post handling help
#1

[eluser]Unknown[/eluser]
I been have at this for a while and tried to search for solution all over the net.
So I am trying to query a list of all the books from the database and populating the title in a dropdown list for the user to select. When I try to send the selected value to the controller, the data is somehow not getting there. The user would select a book title and the respectively id would be passed to the controller. I tried to use POST[''] to retrieve it in controller but I had no luck. I was wondering if someone could kindly give me some help or tell me if this is even possible. Thank you

Code:
//Controller
public function get_C(){
   $this->load->helper("form");
   $this->load->model("booksmodel");
   $data['books'] = $this->booksmodel->getall_entry();
   $this->load->view("booksviewall", $data);
}

//Model
   public function getall_entry(){
   $query = $this->db->query("SELECT * FROM books");
   return $query->result();
}

//View
echo form_open('send');
$list = array();
foreach($books as $row)
{
   $list[$row->id] = $row->title;
}
  
echo form_dropdown('books', $list);
echo form_close();

echo form_submit('books', 'Submit!');
$this->input->post('books');




Theme © iAndrew 2016 - Forum software by © MyBB