Multiple Name Array


I’ve got a situation where I am displaying all files contained in a directory in a multiple select box, so the user can move filenames from the available list of files to a selected list. To demonstrate:

Available Files__________Selected Files

dog.txt_________< >
cat.txt__________< >
bird.txt__________< >
fish.txt__________< >

User selects “cat” and “fish”…

Available Files__________Selected Files

dog.txt_________< >________cat.txt
bird.txt _________< >_______fish.txt

What I need to figure out is how to code php to insert the array (in this case (cat.txt, fish.txt) into my MYSQL table.

Here’s the code I have controlling the multiple select boxes (note: $array contains the filenames from the directory the user is looking at)…

echo "<select multiple name=fromBox id=fromBox>";

if ($array)

foreach ($array as $value)
echo "<option>" . $value . "</option><br>";
echo "</select>";
echo "<select multiple name=toBox id=toBox>";
echo "</select>";

So, I need to capture the results of $value from “toBox”.

Any thoughts, suggestions, etc.?

Thanks in advance!

I don’t think there’s a possibility to read all values of a certain select element? Only the selected items will get carried over AFAIK. That way, you don’t need a second select element either. Not sure, but I don’t think non-selected items get carried over in POST data.

Sponsor our Newsletter | Privacy Policy | Terms of Service