Welcome Guest, Not a member yet? Register   Sign In
[solved]Invalid argument supplied for foreach() - Line 331 form_helper
#11

[eluser]SitesByJoe[/eluser]
[quote author="Jônatan fróes" date="1311795072"]
Code:
form_dropdown ( 'iam_the_input_name', $iam_an_array;, $iam_the_selected_value);
[/quote]

If you read over the quote above, you'll see that form_dropdown wants 3 values:

1. name of the select field
2. array of selectable values
3. the selected value (optional)

Your 2nd parameter is a single string - do you plan for the select to only offer one option that is the name maybe? If that's the case you still would want to make an array with the strong is the first entry.

Does this make sense?
#12

[eluser]brucebat[/eluser]
Yes but I don't know how to build it into an array Sad

Could you show me please?

Would I have to use foreach?
#13

[eluser]brucebat[/eluser]
Nevermind but thankyou for your help!

I got it to work my way of doing it.

So thats all that matters in the end

Here is my code I used if anyone is interested:

Code:
<?php
                        for ($i=0; $i < 5; $i++)
                        {
                            
                            ?&gt;
                            <select>
                                &lt;?php
                                    echo '<option value="NULL">Select Staff</option>';
                                    foreach ($formdata as $row)
                                        { ?&gt;
                                            <option value="&lt;?php echo $row->staff_id; ?&gt;">&lt;?php echo $row->name; ?&gt;</option>
                                        &lt;?php
                                        
                                        }  
                                        
                                
                            echo '</select>';
#14

[eluser]danmontgomery[/eluser]
Code:
$select = array('NULL' => 'Select Staff');
foreach($formdata as $row) {
    $select[$row->staff_id] = $row->name;
}

for($i = 0; $i < 5; $i++) {
    echo form_dropdown('staff[]', $select, set_value("staff[$i]"));
}




Theme © iAndrew 2016 - Forum software by © MyBB