Welcome Guest, Not a member yet? Register   Sign In

Hi all,

Im new here and at CodeIgniter. Im doin a little project and ran into som problems. Donno if this question is OK with you, it contains a little bit of jQuery too.

I have a jQuery list (not really important if its jQ or not..) with "expenses", when I click one of my expenses theres a little dropdown-form (jQuery) with the values of my expense. (Its an economy project)

My question is how do I get the value from my expense to be filled in to my form so that I can edit the expense? Ive tried the urisegment, tho I dont get it to work. Code Below.

Thank you, Beasten

<div id="top10">
                    $user_id = $this->session->userdata('USERID');
                    $query = mysql_query("SELECT * FROM EXPENSES WHERE USERID =     $user_id ORDER BY DATE DESC LIMIT 10");
                        while ($result = mysql_fetch_array($query)) {
                            echo ("<li><a href='$result[0]/#editField'>$result[2]
            <div id="editField">
                &lt;input name="edit" type="text" value="&lt;? echo $this-&gt;uri->segment(4); ?&gt;">
                &lt;input type="submit" value="Change"&gt;

[eluser]Thorpe Obazee[/eluser]
i didn't read the problem or some of the code well. I have one comment though. Why are you loading the database class in the view?

Thats a mistake, missed it. ( beginner at this Wink )

Is there some other way than with urisegment?

You could have them passed into the controller as variables, and then pass them into the view

How do I pass them into the controller?

Its in the user guide Smile


I'm not sure if I understand your problem, but if you want to populate a drop down box with values from your database this should work.

You should have a model, and in that model a function like this:
function drop_down_data()
        $data = array();
        $this->db->select('your_field'); //Put your field name here
        $this->db->from('your_table'); //Put your table here
        $query = $this->db->get();
        foreach($query->result_array() as $row)
            $data[$row['your_field']] = $row['your_field'];
        return $data;

Now in your controller you should have something like this:

function get_drop_down_data()
        $data['somestuff'] = $this->your_model->drop_down_data();
        $this->load->view('your_view', $data);

And in your view, make the form *NOTE* that I'm using the form helper here (have a look in the user guide) and you will need to do all the other stuff. But this will now give you a select with your values.

echo '<p>'. form_label('Some Name','your_field');
    echo form_dropdown('your_field', $somestuff) .'</p>';

Theme © iAndrew 2016 - Forum software by © MyBB