Jump to content

post or get arrays


hyster

Recommended Posts

i have a form that im trying to pass an array that can be a diffrent amount off values.

 

the get string is .php?sel%5B%5D=225&sel%5B%5D=227&sel%5B%5D=232

 

the values need to be stored in a DB and used at a later date in another page to pull the data back so i need to pull it back out so i can loop the sql (select from database where id = 'array').

 

the code im trying to use to use the data is (just want to get the data atm)

echo 'Hello ' . htmlspecialchars($_GET["sel"]) . '!'

 

but i get an error htmlspecialchars() expects parameter 1 to be string.

 

ive never had to work with an array this way and im pulling my hair out :(

 

thanks

Link to comment
Share on other sites

from what ive read i need to pass the array from the form as ( name="sel[]" ) which results in .php?sel%5B%5D=225&sel%5B%5D=227&sel%5B%5D=232

if i remove the [] i get .php?sel=225&sel=227&sel=232 and can only get the last entry.

 

from what i understand the %5B%5D represents the [] in the url.

 

 

ive removed most of the php and left the java out as this part works ok.

 

 <FORM onsubmit="placeInHidden('.', 'sel3', 'hide2');" method="get"
 action="insert_tanks.php"><SELECT id="sel3" multiple="multiple" size="5">
 <?php

?>
 <option value="<?php echo $row['list']; ?>"><?php echo $row['tier']." - ".$row['name']; ?></option>

 </SELECT><INPUT id="hide2" name="hide2Name"
 type="hidden"><BR></FORM></TD>
<TD vAlign="middle" align="center">
 <FORM><INPUT onclick="moveOptions(document.getElementById('sel3'), document.getElementById('sel4'));" value="-->" type="button"><BR><INPUT onclick="moveOptions(document.getElementById('sel4'), document.getElementById('sel3'));" value="<--" type="button"></FORM></TD>
<TD>
 <FORM onsubmit="selectAllOptions('sel4');" method="get" action="insert_tank.php">
	 Auto-select<BR><SELECT id="sel4" multiple="multiple" size="5" name="sel"></SELECT><BR><INPUT value="Submit" type="submit"></FORM>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.