3
I am trying to retrieve from the database a string in a field dropdown of a form on a page of update, my view goes below.
$option = array(NULL => 'Selecione uma categoria');
foreach ($categories_list->result() as $category):
$option[$category->categoryID] = $category->categoryTitle;
endforeach;
echo form_dropdown('categoryname', $option, set_value('categoryname', $post->categoryTitle));
However, the dropdown does not display the database string. Could someone help me?
Hello Zuul, it really didn’t work. There is no way to display dorpdown with the saved option in the bank.
– Downbeat
@Downbeat ?? It has to work, when you query something in the database you get one array, the
foreach
reads every entry of array and build another array in the way that the helperform_dropdown
hope to receive. Not to be working, the only thing I can think of is that what you get from the comic book is not what you expected...– Zuul
I’m sorry, maybe I’m having a hard time formulating the question correctly. I need to display the option selected by the user and saved in the database on a page that must return all fields of the form to perform a possible update of the data. With the other fields I did so and it worked:echo form_input(array('name' => 'postname'), set_value('postname', ucwords($post->postTitle)));
– Downbeat