vendredi 18 mars 2016

PHP handling combined checkboxes and select boxes

I'm working on a form that uploads an image to a server. The form contains checkboxes and select boxes formatted to a . Each table rows contains two columns. The First column iterates through a mysql query that displays a list of items (24 items to be exact) that is paired to a checkbox. The 2nd column iterates through a mysql query that displays list of clients.

screenshot here

What needs to be done are as follows:

  1. When the form gets uploaded (via POST or GET) the checkboxes which only have check gets passed.
  2. convert the subs_id (name parameter for the select box) to an array for easy processing for mysql insert.

Code Below. Thanks in advanced!

<form method="post" enctype="multipart/form-data" action="upload2.php">
        Name: <input type="text" name="item_desc" value=""> 
        Show Date: <input type="text" name="upload_date" class="date" size="10"> to <input type="text" name="expiry_date" class="date" size="10">
        Item: <input type="file" name="item"> Display Length: <input type="number" value="8" name="show_time" size="3" style="width:50px"> secs 


        <table class="data-list" width="100%">
            <tr>
                <td>Widget</td>
                <td>Client</td>
            </tr>   

            <?php foreach($instance as $item):?>
            <tr>
                <td><input type="checkbox" id="checkAll"/>&nbsp;&nbsp;<?php echo $item['name']; ?></td>
                <td><select id="selectBox" name="subs_id[]">
                    <option selected="selected" value="none">Select Client</option>
                    <?php foreach($subs as $client): ?>         
                        <option value="<?php echo $item['id'] . '-' . $client['id']; ?>" client="<?php echo $client['client_name']; ?>" ><?php echo $client['client_name']; ?></option>
                    <?php endforeach ?>
                    </select>
                </td>
            </tr>   
            <?php endforeach; ?>
        </table>        
        <br>
        <input type="submit" value="upload">
    </form>




Aucun commentaire:

Enregistrer un commentaire