Solved

Move Items between select boxes

Posted on 2003-11-22
1
307 Views
Last Modified: 2012-08-13
I have two select boxes.  The first is populated from PHP:

$query="SELECT page_permissions.page_id,pages.page_name FROM page_permissions INNER JOIN pages ON page_permissions.page_id = pages.page_id WHERE page_permissions.user='" . $_SESSION['username'] . "'";

$result1 = mysql_query($query);
while($row = mysql_fetch_array($result1))
{
    $toprint="<option value=\"$row[page_id]\">$row[page_name]\n";
    print($toprint);
}


What I want to do is have two buttons, a "->" that will place the selected element from the first box into the second box and "<-" that will remove the item selected in the second box.  Then, once the user is done adding elements into the second select box, I want to INSERT those values into my MySQL database using PHP.  I have been strugging with this for about 8 hours now and realized it was time to ask for help.  I'm having all kinds of issues with this (I can't get multiple 'submit' buttons to work without reloading the page wrong, etc.).  Basically, I'm starting out in this and it's my first web development experience and it's not treating me well.  I realize this is a question with a huge scope, so I made it worth alot of points and I can split them if you dont' have time to answer all the issues right at once.

Thanks ahead of time for your help.

Chad
0
Comment
Question by:mistaeverly
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 13

Accepted Solution

by:
lozloz earned 250 total points
ID: 9806301
first you want to be doing this through javascript i think:

http://javascript.internet.com/forms/form-swapper-2.html

that seems to be the script you want. all you want to do there is replace the name="list1" for name="items[]", replace all the options with your PHP query above, and have a submit button point to a page to do the processing. then your processing page (could be the same page) will just do:

foreach($_POST["items"] as $key => $val) {
  $query = "INSERT INTO table (column1, column2) VALUES ('$key', '$val')";
  $result = mysql_query($query) or die(mysql_error());
}

if you need any more help then ask away

loz
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question