Welcome Guest, Not a member yet? Register   Sign In
How do I make this work? - RESOLVED
#1

[eluser]mousewonders[/eluser]
I am very new to CI. Just started playing with it tonight. I am trying to create a event manager.

I am trying to pull data from a database to be editted. This is what I have so far..

Code:
function edit()
    {
    $getid = $this->uri->segment(4); // This line gets the ID of the event to edit...
    $where = 'event_id = $getid'; // I am sure there is a better way.. but this is my where clause.
    $data['query'] = $this->db->get('events', $where); // I believe pulls the row.
    $query->result() as $row:; // This doesnt work... not sure how to pull without a foreach.
    echo form_input('username', $row->event_title);// Here I want the form to be created with the values filled in from the database...


}

I currently have only two fields that I need created that is event_title and event_details.
I believe everything up to $query->result is working.... I think... anyways.. Thanks for your assistance.

Richard
#2

[eluser]Caelis[/eluser]
instead of
$data['query'] = $this->db->get('events', $where);
put
$query = $this->db->get('events', $where);

then (not totally certain of the foreach-syntax and too lazy to check :p)

foreach ($query->result() as $row) :
echo form_input('username', $row->event_title);
endforeach;
#3

[eluser]wiredesignz[/eluser]
Try:
Code:
$query = $this->db->get_where('events', array('event_id' => $getid));

EDIT: corrected for 1.6.1, $where is indeed an array now
#4

[eluser]Ryuuzaki92[/eluser]
$where should be an array:

Code:
$where = array('event_id' => $getit);

to get the row, you should do this:

Code:
$result = $this->db->get('events', $where);
$row = $result->row();
echo form_input('username', $row->event_title);
#5

[eluser]mousewonders[/eluser]
Ryuu - Prefect! Thanks a million you fixed my problem... Thanks to you others who tried to help me as well!




Theme © iAndrew 2016 - Forum software by © MyBB