Welcome Guest, Not a member yet? Register   Sign In
how to save the data from the listbox to the database
#1

[eluser]basty_dread[/eluser]
I have this listbox and the data from my listbox is from the database. i already have the code for customizing the order of each data. what i need is to save these data that i customize the order. how could i save it to the database? any one please help me. Thank you very much,,
#2

[eluser]basty_dread[/eluser]
Please help me on my project.. thank you very much.. Im a newbie in CI
#3

[eluser]Thorpe Obazee[/eluser]
It's really difficult to help you. You should probably explain better.
#4

[eluser]basty_dread[/eluser]
Im sorry if i did not explain it clearly.

i have a listbox.
and it's values are fetched from the database so this is how it will look like:

listbox name="list"
____________________
one
____________________| <---- this values are from the database
family tree
____________________|
ampster is amps
____________________|


what i want is to POST all the values on the listbox to the next page.
what should i do so that i could get all the values and insert them to the database.

Any one please help me please.. Thank you.
#5

[eluser]basty_dread[/eluser]
any one please help me? is there any way like that?
#6

[eluser]Thorpe Obazee[/eluser]
Listbox is the same as

Code:
<SELECT NAME=sections MULTIPLE>
<OPTION>Web Authoring Reference</OPTION>
<OPTION>FAQ Archives</OPTION>
<OPTION>Design Elements</OPTION>
<OPTION>Tools</OPTION>
<OPTION>Feature Article</OPTION>
</SELECT>

Right?

I believe you have to select all the values and then submit the form then save using this:

http://ellislab.com/codeigniter/user-gui...tml#insert
#7

[eluser]khagendra[/eluser]
Will you please put your code detail. :question:
However go through this link, it will help u to understand.

Code:
http://ellislab.com/forums/viewthread/133105/#656950
#8

[eluser]basty_dread[/eluser]
i have to select all the values how could that be possible? using a javascript?


putting the values in an array is my problem as well.
#9

[eluser]basty_dread[/eluser]
[quote author="bargainph" date="1256882939"]Listbox is the same as

Code:
<SELECT NAME=sections MULTIPLE>
<OPTION>Web Authoring Reference</OPTION>
<OPTION>FAQ Archives</OPTION>
<OPTION>Design Elements</OPTION>
<OPTION>Tools</OPTION>
<OPTION>Feature Article</OPTION>
</SELECT>

[/quote]


it's not actually a multiple select.

just this
Code:
<SELECT NAME=sections>
<OPTION>Web Authoring Reference</OPTION>
<OPTION>FAQ Archives</OPTION>
<OPTION>Design Elements</OPTION>
<OPTION>Tools</OPTION>
<OPTION>Feature Article</OPTION>
</SELECT>

how can i POST all of these values to my next page, so that i could insert these items on my database.
thanks.
#10

[eluser]khagendra[/eluser]
Here is modification of your view file v_example.php to submit all the selected values

-- view (v_example.php) --
Code:
&lt;form action="&lt;?=site_url('example/multiple')?&gt;" method="post"&gt;
    <SELECT NAME="sections[]" MULTIPLE>
    <OPTION value="Web Authoring Reference">Web Authoring Reference</OPTION>
    <OPTION value="FAQ Archives">FAQ Archives</OPTION>
    <OPTION value="Design Elements">Design Elements</OPTION>
    <OPTION value="Tools">Tools</OPTION>
    <OPTION value="Feature Article">Feature Article</OPTION>
    </SELECT>
    
    &lt;input type="submit" value="Submit" /&gt;
&lt;/form&gt;

-- Controller (example.php) --
Code:
class Example extends Controller {
    
    function Example()
    {
        parent::Controller();
        $this->load->helper('url');
        $this->load->library('form_validation');
    }
    
    function index()
    {
        $this->load->view('v_example');
    }
    
    function multiple()
    {
        foreach($_POST['sections'] as $sec)    
        echo $sec."<br>";    
    }
}

I have listed the selected values form the list.
Hope this will help u

Enjoy! :-)




Theme © iAndrew 2016 - Forum software by © MyBB