PHP 8 Select2 for Multiple Select Example Tutorial

May 24, 2022 . Admin

Hello Friend,

This article will give you example of PHP 8 select2 for Multiple select Example Tutorial. if you want to see example of How to use select2 for multiple select in PHP 8? then you are a right place. this example will help you Select2 - The jQuery replacement for select boxes in PHP 8.

we will help you to give example of How to get multiple selected values of select box in php 8?.

I explained simply about How to get multiple selected values of select box in php 8?

<html lang="en">
    <title>PHP 8 Select2 for Multiple Select Example Tutorial</title>
    <link rel="stylesheet" href="" integrity="sha256-aAr2Zpq8MZ+YA/D6JtRD3xtrwpEz2IqOS+pWD/7XKIw=" crossorigin="anonymous" />
    <script src="" integrity="sha256-OFRAJNoaD8L3Br5lglV7VyLRf0itmoBzWUoM+Sji4/8=" crossorigin="anonymous"></script>
    <script src="//"></script>
    <link href="" rel="stylesheet" />
    <script src=""></script>
    <div class="row mt-5">
        <div class="col-md-6 offset-3 mt-5">
            <div class="card">
                <div class="card-header bg-info text-white">
                    <h4>PHP 8 Select2 for Multiple Select Example Tutorial -</h4>
                <div class="card-body" style="height: 280px;">
                    <form action="multiSelectPro.php" method="post">
                        <div class="form-group">
                            <label>Title :</label>
                            <input type="title" name="title" class="form-control">
                        <div class="form-group">
                            <label>Category :</label>
                            <select class="category related-post form-control" name="category[]" multiple>
                                <option value="1">Laravel</option>
                                <option value="2">Jquery</option>
                                <option value="3">React</option>
                                <option value="4">Jquery ui</option>
                                <option value="5">Android</option>
                                <option value="6">React Native</option>
                                <option value="7">Vue js</option>
                                <option value="8">Bootstrap 4</option>
                        <div class="form-group">
                            <button class="btn btn-success store-related-post btn-sm">Save</button>
    <script type="text/javascript">
        $(document).ready(function() {
    define (DB_USER, "root");//Username
    define (DB_PASSWORD, "root");//Password
    define (DB_DATABASE, "new_blog"); //Database Name
    define (DB_HOST, "localhost");
    $mysqli = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_DATABASE);

    $title = $_POST['title'];
    $category = implode(', ', $_POST['category']);
    $created_at = date();

    $sql = "INSERT INTO posts (title,category) VALUES ('$title', '$category')";
    $result = $mysqli->query($sql);

Output :

It will help you...
#PHP 8