I have a multiple option select which populate data from MySQL but select first element from html. I do not want to store first element in db

This is the html form multiple select list. list option are populated from database. But when I submit the form it also stores <option value="0">Select multiple options:</option> if I select it. I just want that either it is selected or not it should not be stored in db. Thanks in advance.

function setdbSelect() {
            $result1 = Plusql::from($this->profile)->courses->select('*')->run()->courses;
            foreach ($result1 as $value){
            echo $result1->course_id;
            }
            $options = array();
            foreach ($result1 as $value) {
                //$this->template->setValue('#stu_courses', $result1->course_name);
                $options[$result1->course_id] = $result1->course_name;
            }

                \Config\Central::repeat_select_options($this->template, "#stu_courses", $options, 0);

        }
<p>
  <label for="stu_courses">Courses:</label>
  <br/>
  <select id="stu_courses" name="stu_courses[]" multiple="multiple">
    <option value="0">Select multiple options:</option>

  </select>
</p>


Download i.have.a.multiple.option.select.which.populate.data.from.mysql.but.select.first.element.from.html.i.do.not.want.to.store.first.element.in.db.zip
Direct Link


Download


Download i.have.a.multiple.option.select.which.populate.data.from.mysql.but.select.first.element.from.html.i.do.not.want.to.store.first.element.in.db.zip
Mediafire


Download


Download i.have.a.multiple.option.select.which.populate.data.from.mysql.but.select.first.element.from.html.i.do.not.want.to.store.first.element.in.db.zip
Nornar


Download

Both comments and pings are currently closed.

Comments are closed.