Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8927415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:13:11+00:00 2026-06-15T08:13:11+00:00

i am using the following multiselect box to take input from users, this then

  • 0

i am using the following multiselect box to take input from users, this then gets posted to my php form which adds it to the database, the problem is, all I am getting added is the first selection, if the user selects more than one field I still only get the first field.

If the user selects lets say internet, drawing,maths I want that to be put into the database, at the moment all that is inserted is internet, or whatever is the first thing selected in the list.

My form looks like this >>

    <form action="../files/addtodb.php" method="post" style="width:800px;">
    <select name="whatisdeviceusedfor[]" size="1" multiple="multiple" id="whatisdeviceusedfor[]">
        <option value="games">Games</option>
        <option value="takingphotos">Taking Photos</option>
        <option value="maths">Maths</option>
        <option value="reading">Reading</option>
        <option value="drawing">Drawing</option>
        <option value="internet">Internet</option>
        <option value="other">Other (enter more info below)</option>
      </select>
      <input type="submit" name="submit" id="submit" value="Submit">
      </form>

The php side looks like this >>

 <?php

 // Implode what is device used for
$usedfor = $_POST['whatisdeviceusedfor'];
$arr = array($usedfor);
$whatisdeviceusedfor = implode(" ",$arr);



// Insert posted data into database
mysql_query("INSERT INTO itsnb_year5questionaire (whatisdeviceusedfor) VALUES   '$whatisdeviceusedfor'") or die(mysql_error()); 

   ?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T08:13:12+00:00Added an answer on June 15, 2026 at 8:13 am

    you are already getting array by select so you dont need to use $arr = array($usedfor);this again

    just try

    $usedfor = $_POST['whatisdeviceusedfor'];
    
    $whatisdeviceusedfor = implode(" ",$usedfor);
    

    or

    $usedfor = $_POST['whatisdeviceusedfor'];
    
    
    $strings ='';
    foreach ($usedfor as $item){
        $strings .=' '. $item;
    }
    echo $strings;
    

    and

     <select name="whatisdeviceusedfor[]" size="5" multiple="multiple" id="whatisdeviceusedfor[]">
                                               ^^             
                                               ||change to option you want to select 
    

    i have changed size="5" so it will select now 5 at a time …you have only 1 so it will let only 1 select at a time

    result

    enter image description here

    warning

    your code is vulnerable to SQL injection also use of mysql_* function are deprecated use either PDO or MySQLi

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using following code to get bitmap from url. This function is used
I am using following code to show a spinning wheel: $(#loading) .hide() .ajaxStart(function(){ $(this).show();
Using following Options +FollowSymlinks RewriteEngine on RewriteCond %{REQUEST_URI} !/temp_page.php$ RewriteCond %{REQUEST_URI} !/thanks.php$ RewriteCond %{REMOTE_HOST}
I am using following code to detach my DB from SQL Server express. Please
I'm using the following jquery multiselect plugin ... How can I grab the selected
I'm using the following jquery multiselect plugin ... How can set the selectedText as
Using following mysql query: SELECT DATE_FORMAT(time, '%Y-%m-%d') AS time,report,count(ip) AS countip FROM asn_data WHERE
I am using following code to make a phone call from my iPhone app:
Using the following HTML input and Javascript, a user can add up to 3
Iam Using following code to run this event using IF CURRENT_TIME() = '23:50:00' But

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.