Select multiple items from dropdown and send to database

I have a form with this field in it. Which calls from a skills table that has 2 columns – the skill_id(int) and the skill(varchar). I want the user to choose multiple choices for the skills they have and add this to their information but only 1 choice is going through.

print ("<tr><td valign=top>Skill: </td><td><select name=uskill_id[0] size=3 multiple=multiple>");


  global $wpdb;
  $trade = $wpdb->get_results("select skill, skill_id from wp_skill", ARRAY_A);
  foreach($trade as $row) {
      $skill = $row['skill'];
      $skill_id  = $row['skill_id'];
      print '<option value="'.$skill_id.'">'.$skill.'</option>';
}

Here is the insert statement which will send the info to the database. The skill_id I have turned into a varchar type from an int type but still no luck.

global $wpdb; $success=$wpdb->insert('trades', array('skill_id' => explode(', ', $_POST['uskill_id[0]'])));

Related posts

1 comment

  1. <"?php          if($_POST){
                    $uskill_id              =   implode(", ",$_POST['uskill_id']);
    
                    echo $uskill_id;//to data base          } ?>
    

    use this form

                <label for="uskill_id" >Skils </label><br/>
    
                <select name="uskill_id[]"   id="uskill_id" multiple="multiple" data-placeholder="Click to select..." >
               <option value="1">English Writing </option>
                <option value="2">Blog Writing </option>
                 <option value="3">Article  Writing </option>
                  <option value="4">Book Writing </option>
    
               </select>
    
    
           <input type="submit" value="Submit" />
    
             `
    

Comments are closed.