Q:

pass selected option value with an id via URL

I'm new to PHP and I'm trying to pass the value of option value in the select through the URL with the id.But I'm having trouble with implementing the logic to send the option value in the URL itself with the id.I know that I can send the value using POST method. But if I use POST method how can I pass id to the model.
This is the code that contains the select options and the URL that I'm trying to pass the parameters.
 <div class="table-responsive" ">
<table class="table">
    <thead class="thead-dark">
    <tr>
        <td>#</td>
        <td>Task</td>
        <td>Status</td>
        <td>Action</td>
    </tr>
    </thead>
    <tbody>
    <?php
    $data = new tasks();
    $set = $data->get();
    foreach ($set as $row) {

        ?>
        <tr>
            <td><?= $row['id'] ?></td>
            <td><?= $row['name'] ?></td>
            <td>
                <select name="status" id="status">
                    <option value=""><?= $row['status'] ?></option>
                    <option value="Completed">Completed</option>
                    <option value="Currently Working">Currently Working</option>
                    <option value="Have To Start">Have To Start</option>
                </select></td>
            <td>
                <a href="task.php?status=<?= $row['status'] ?>&id=<?= $row['id'] ?>" type="submit"  class="btn btn-update" name="update">Update</a>
                <a href="task.php?delete=<?= $row['id'] ?>" type="submit"  class="btn btn-delete" name="delete">Remove</a>
            </td>
        </tr>

    <?php } ?>

    </tbody>
</table>

Any kind of help would be highly appreciated.

A:

Since in the comment you have mentioned that you are still confused on what exactly you should do, I will explain further.
Since you are trying to  change the href based on the option that is selected by the user from the drop down you will need JavaScript instead of PHP, since it's client-side logic.
in your php view file:
foreach ($set as $row) {

        ?>
        <tr>
            <td><?= $row['id'] ?></td>
            <td><?= $row['name'] ?></td>
            <td>
                <select name="status" id="status">
                    <option value=""><?= $row['status'] ?></option>
                    <option value="Completed">Completed</option>
                    <option value="Currently Working">Currently Working</option>
                    <option value="Have To Start">Have To Start</option>
                </select></td>
            <td>
                <a type="submit"  onclick="status(<?= $row['id'] ?>)" class="btn btn-update" name="update">Update</a>
                <a href="task.php?delete=<?= $row['id'] ?>" type="submit"  class="btn btn-delete" name="delete">Remove</a>
            </td>
        </tr>

    <?php } ?>

Here what you should do is call a function that is made in js called status and pass the
$row['id'] since you need the id to update a data set.And then you can handle the logic related to location change and sending status,id in the function
in js:
function status(id) {

    var sel = document.getElementById("status");
    var text = sel.options[sel.selectedIndex].text;

    window.location.href="task.php?update="+text+"&id="+id;
}

Here what you can do is, you can assign the value of status using document.getElementById.And then assign the id and the status value to the URL and redirect to the URL from the function it self.
To read more about getElementById,getElementById you can go to both links that i have mentioned in here.

The getElementById() method returns the element that has the ID attribute with the specified value.
This method is one of the most common methods in the HTML DOM, and is used almost every time you want to manipulate, or get info from, an element on your document.
Returns null if no elements with the specified ID exists.
An ID should be unique within a page. However, if more than one element with the specified ID exists, the getElementById() method returns the first element in the source code.

I hope this will be helpfull.

