Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

"Select Multiple", retrieving array values on next page, PHP

Options
  • 19-05-2005 7:25pm
    #1
    Registered Users Posts: 7,868 ✭✭✭


    The below code creates an array called "skills[]" and sends to page2.php .
    <form action=page2.php method=get>
    <select name="skills[]" multiple>
    
    <option value="degree">IT DEGREE</option>
    <option value="msce">MSCE</option>
    <option value="fas">FAS</option>
    <option value="diploma">IT DIPLOMA</option>
    <option value="msoffice">MS OFFICE</option>
    <option value="linux">LINUX</option>
    
    </select>
    <input type=submit>
    </form>
    

    The querystring is ".../page2.php?skills%5B%5D=msce&skills%5B%5D=fas" if MSCE and FAS are selected, for example. Problem is i dont know how to access the elements. Google only has examples of sending to the same page and i cant figure out how to adapt them. does anyone know how i can display a list of everything in the array on the following page? i tried
    foreach ($_GET['skills'] as $k => $v)
            {
            echo $skills[$k] . " : " . $skills[$v] ."<br>";
            }
    
    but its not workin.




    /EDIT: actually, it works if i do this:
    $num=count($_GET['skills']);
    echo "You selected " .$num ." choices<br>";
    for ($i = 0 ; $i < $num ; $i++)
            {
            echo $_GET['skills'][$i] ."<br>";
            }
    
    thanks anyway. ;)


Comments

  • Registered Users Posts: 1,268 ✭✭✭hostyle


    foreach ($_GET['skills'] as $k => $v)
            {
            echo $k . " : " . $v ."<br>";
            }
    


Advertisement