mardi 1 décembre 2015

Checkbox option to produce an SQL result

what function should I use to obtain a "Y" if the checkbox has been selected or "N" if it has not. This is to add into a SQL statement? I'm guessing it is an if/else but I can't figure it out.

Here is my checkboxes which some may be selected individually:

                        <label class="timetable-q">Data Projector</label>
                        <input type="hidden" id="proj_check" name="proj_check" value="Y"/>
                        <input type="checkbox" id="proj_check" name="proj_check" value="N"/>
                        <label class="timetable-q">Whiteboard</label>
                        <input type="hidden" id="white_check" name="white_check" value="Y"/>
                        <input type="checkbox" id="white_check" name="white_check" value="N"/>
                        <label class="timetable-q">OHP</label>
                        <input type="hidden" id="ohp_check" name="ohp_check" value="Y"/>
                        <input type="checkbox" id="ohp_check" name="ohp_check" value="N"/>
                        <label class="timetable-q">Wheelchair Access</label>
                        <input type="hidden" id="wheel_check" name="wheel_check" value="Y"/>    
                        <input type="checkbox" id="wheel_check" name="wheel_check" value="N"/>                                  
                        <label class="timetable-q">Lecture Capture</label>
                        <input type="hidden" id="cap_check" name="cap_check" value="Y"/>
                        <input type="checkbox" id="cap_check" name="cap_check" value="N"/>
                        <input type="submit" value="submit">
                        </p>
                        </form>

Here is my PHP:

<?php 
                        $numeroOption= $_POST['numero'];
                        $selectOption = $_POST['parkname'];
                        $query = "SELECT * FROM `ROOMS` WHERE `Capacity` < '$numeroOption' AND `Park` LIKE '$selectOption%'"; 
                        $result = mysql_query($query);
                        echo $result;
                        if ($result == FALSE) die ("could not execute statement $query<br />");
</php>

Thanks for your help!




Aucun commentaire:

Enregistrer un commentaire