Jump to content


Photo

Multiple selected values from listbox to database


  • Please log in to reply
2 replies to this topic

#1 gopi_crishna

gopi_crishna
  • Members
  • Pip
  • Newbie
  • 3 posts

Posted 21 October 2004 - 06:23 PM

Hi ,
I am trying to select multiple values from a listbox and then pass all the selected values into the one field of the database ..i am not able to get that right ..

when i add this line of code

<select name="source_info[]" size="10" multiple>


something like "array" is getting stored in the database field instead of the selected items ..can any one help me in this

Thanks

Gopi


#2 ashoogy

ashoogy
  • Members
  • Pip
  • Newbie
  • 5 posts

Posted 31 October 2004 - 10:32 AM

hi there

in your script(i.e. the one that recieve the array) try to loop through the array
one by one and store each value. to be more clear:

let us assume that we are having the following array:
$select
use the following code to loop through array)
foreach ( $select as $mydata)
{
$result = mysql_query("insert into mytable(colsname) values('$mydata')");
}

try it and let me know if you need further help

#3 theatrehelper

theatrehelper
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 11 February 2005 - 08:59 PM

hi there

in your script(i.e. the one that recieve the array) try to loop through the array
one by one and store each value. to be more clear:

let us assume that we are having the following array:
$select
use the following code to loop through array)
foreach ( $select as $mydata)
{
$result = mysql_query("insert into mytable(colsname) values('$mydata')");
}

try it and let me know if you need further help

View Post


Where exactly does one place this code? For example, I have the array created, but have no clue how to put that array into the database...




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users