dimanche 10 janvier 2016

PHP, checkboxes

I have a gallery where there are images and next to the images are checkboxes. When for exmaple user click 3 of checkboxex and a submit button i would like to save these 3 images in session to show them in the other gallery (of chose images). Now my code looks like this:

<?php if ($images->count()): ?>
        <?php foreach ($images as $image): ?>
             <tr>
                <td><?= $image['title'] ?></td>
                <td><?= $image['author'] ?></td>
                <td class="image">
                    <a href="static/images/<?= $image['file_name'] ?>">
                        <img class="gallery" src='static/images/<?= $image['file_name']?>'>
                    </a>
                </td>
                <td>
                <form action="gallery" method="post" class="wide"/>
                    <input type="hidden" name="id" value="<?= $image['_id'] ?>"/>
                    <input type="checkbox" name="ckeckbox"/>
                    <input type="submit" name="gallery" value="Zapamiętaj"/>
                </form>
                </td>
            </tr>
        <?php endforeach ?>
    <?php endif ?>

It works but the problem is, that all images have own buttons and I would like to have one universal button to accept all clicked checkboxes. How can I do this?




Aucun commentaire:

Enregistrer un commentaire