Hi!

Could anyone help me to add some PHP to the following Javascript:

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

What I am trying to build is a system where the SELECT from the left should be loaded from a mySQL table and then, after choosing 2 or 3 items, be able to obtain a PHP array with the chosen items on the right...

I will apreciate your kind help!
Thank you very much

    here the BASIC idea

    // assuming already connected to db
    $result = mysql_query('SELECT * FROM table');
    
    echo '
    <form action="' . $_SERVER['PHP_SELF'] . '" method="POST">
    <select name="list[]" multiple>
    ';
    
    while ($row = mysql_fetch_assoc ($result))
    {
    	echo '<option>' . $row['field'] . "\n";
    }
    
    echo '
    </select><br>
    <input type="submit" name="submit" value="submit">
    </form>
    ';
    
    if (isset($_POST['submit']))
    {
    	if (isset($_POST['list']))
    	{
    		echo 'you selected:<br><br>';
    		foreach ($_POST['list'] as $value)
    		{
    			echo stripslashes($value) . '<br>';
    		}
    	}
    	else {echo 'you did not select anything';}
    }
    

      Thank you so much!!!

      This is a very good start...

      What is difficult for me in this case is to make the Javascript code to interact with PHP to pass the 2nd SELECT contents...

        Write a Reply...