P
P
plmax2015-10-07 12:46:55
PHP
plmax, 2015-10-07 12:46:55

How to get a button press with a set of different names via POST?

<form method="post">
    <table>
        <tbody>
        <?php
        $projects = project_view();
        foreach ($projects as $project) {
            ?>
            <tr>
                <td><?php echo $project['id']; ?></td>
                <td><?php echo $project['name']; ?></td>
                <td><input type="submit" class="button" name="<?php echo $project['id'] ?>" value="Удалить"></td>
            </tr>
            <?php
        }
        ?>
        </tbody>
    </table>
</form>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivanq, 2015-10-07
@Ivanq

First, replace <?php echo $project['id'] ?>with <?=$project['id']?>.
Secondly:

<?php
        $projects = project_view();
        foreach ($projects as $project) {
               if(isSet($_REQUEST[$project['id']])) {
                       echo "It's " . $project['name'];
                       break;
               }
         }
?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question