lundi 10 octobre 2016

Retrive data from database and explode and based on that select checkbox

I am retrieving data from MySQL database and explode it, based on result i want to select multiple checkbox, I am pasting my PHP code and all the checkbox code as well as database so you can see which checkbox must be selected based on result.

<?php 
                            $query25 = "SELECT * FROM es_availability_options WHERE es_id='4'"; 
                            $result25 = @mysql_query($query25);
                            echo mysql_error();
                            $row25=@mysql_fetch_array($result25);
                            $availability_options = $row25['availability_options'];
                            $availability_options = explode(', ', $availability_options);

                            ?>

<div class="row">

                        <div class="col-md-4">

                        <p style="font-size:16px;"><input name="availability_options[]" type="checkbox" value="Available by appointment"> Available by appointment</p>
                        <p style="font-size:16px;"><input name="availability_options[]" type="checkbox" value="Pre bookings preferred but can be available at short notice"> Pre bookings preferred, but can be available at short notice</p>
                        <p style="font-size:16px;"><input name="availability_options[]" type="checkbox" value="Flexible hours by appointment"> Flexible hours by appointment</p>
                        <p style="font-size:16px;"><input name="availability_options[]" type="checkbox" value="Available for overseas travel"> Available for overseas travel</p>
                        </div>

                        <div class="col-md-4">
                        <p style="font-size:16px;"><input name="availability_options[]" type="checkbox" value="Available 7 days"> Available 7 days</p>
                        <p style="font-size:16px;"><input name="availability_options[]" type="checkbox" value="12 hours notice required"> 12 hours notice required</p>
                        <p style="font-size:16px;"><input name="availability_options[]" type="checkbox" value="Available outside my city only"> Available outside my city only</p>
                        </div>

                        <div class="col-md-4">
                        <p style="font-size:16px;"><input name="availability_options[]" type="checkbox" value="Available 24 hours"> Available 24 hours</p>
                        <p style="font-size:16px;"><input name="availability_options[]" type="checkbox" value="24 hours notice required"> 24 hours notice required</p>
                        <p style="font-size:16px;"><input name="availability_options[]" type="checkbox" value="Available on weekends only"> Available on weekends only</p>
                        </div>

                    </div><!-- end row -->

Please help me. Thanks!




Aucun commentaire:

Enregistrer un commentaire