[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Move Items between select boxes

Posted on 2003-11-22
1
Medium Priority
?
312 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
1 Comment
 
LVL 13

Accepted Solution

by:
lozloz earned 1000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses
Course of the Month20 days, 2 hours left to enroll

873 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