webdevask.com

Menu

  • Home
  • New
  • Add question

php - multi-select drop-down results shows Array

View Original

im using multi select drop down list im able to select the list i want to update in my database but when i see the results it shows "Array" Instead Of the Selection.

 <select class="selectpicker" multiple data-live-search="true" name="Attendedby" ng-model="Attendedby">
  <option>Mustard</option>
  <option>Ketchup</option>
  <option>Relish</option>
</select>
$('select').selectpicker();

this is mysql preview enter image description here

i dont know why my results display Array, please help

Here is my php

        if($form_data->action == 'Edit')
        {
            $data = array(
                ':Attendedby' =>    $Attendedby,
                ':EndDate'    =>    $EndDate,
                ':Status'     =>    $Status,
                ':Remarks'    =>    $Remarks,
                ':id'         =>    $form_data->id
            );
            $query = "
            UPDATE cov9 
            SET Attendedby = :Attendedby, EndDate = :EndDate, Status = :Status, Remarks = :Remarks
            WHERE id = :id
            ";

            $statement = $connect->prepare($query);
            if($statement->execute($data))
            {
                $message = 'Data Edited';
            }
        }
    }

Answer

Solution:

First of all you need to edit the name of the select to Attendedby[] as it expects multiple values and then use something like this to get multiple data into one column:

$Attendedby = implode(', ', $_POST['Attendedby']);

source

Source

See also:

  • php สร้าง Google ชีตจากบัญชีบริการ

  • php - Laravel 8.0 Installation Failed

  • javascript - How to include HTML data (tags) as value in "arrayToDataTable" of Google Pie Chart?

  • how to Grouping array in php

  • php - vender folder from my laravel project has more 1k error

© 2021
E-mail: contact@webdevask.com
Back to top