Topic: inserting multiple list values in php (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=29251" title="Pages that link to Topic: inserting multiple list values in php (Page 1 of 1)" rel="nofollow" >Topic: inserting multiple list values in php <span class="small">(Page 1 of 1)</span>\

 
tomeaglescz
Paranoid (IV) Inmate

From: Czech Republic via Bristol UK
Insane since: Feb 2002

posted posted 06-03-2007 00:31

ok here is what i am trying to do, i have to create a form where someone can enter a product a link to an image and select which countries its available in.

the structure of the products table is.

material_id int(5)
name varchar(50)
country_id set('1','2','3','4','5','6','7')
photo varchar(100)

the form code is like this:

<select name="country_id[]" size="7" multiple="multiple" id="country_id[]">
<option value="1">Czech Republic</option>
<option value="2">Denmark</option>
<option value="3">Germany</option>
<option value="4">Greece</option>
<option value="5">Norway</option>
<option value="6">Poland</option>
<option value="7">Sweden</option>
</select>

the get part of the insert sql is this

when the form is submitted i get an error country_id cannot be null

the get=GetSQLValueString($_POST['country_id[]'], "int"),

any ideas?

Skaarjj
Maniac (V) Mad Scientist

From: :morF
Insane since: May 2000

posted posted 06-03-2007 04:11

Do you have a default selection value for your list box? And, just to ask a stupid question: your form *is* submitting via POST, isn't it?

Meanwhile, have you tried this?

code:
get = '';
if(isset($_POST['country_id[]']))
{
	$country_id = $_POST['country_id[]'];
	get = GetSQLValueString($country_id, "int");
}




Justice 4 Pat Richard

tomeaglescz
Paranoid (IV) Inmate

From: Czech Republic via Bristol UK
Insane since: Feb 2002

posted posted 06-03-2007 06:21

hi adrian,

got it fixed in the end not sure what was wrong but fiddled and it worked

thx

tom

Tyberius Prime
Maniac (V) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 06-03-2007 13:23

you get an array named $_POST['country_id'] - not a variable named $_POST['country_id[]'],- which can nerver be created by a post request, since php translates the input.

(Edited by Tyberius Prime on 06-03-2007 13:26)



Post Reply
 
Your User Name:
Your Password:
Login Options:
 
Your Text:
Loading...
Options:


« BackwardsOnwards »

Show Forum Drop Down Menu