Passing a variable inside a button in PHP

Viewed 22

I'm trying to pass a variable in a back button, I'm trying to pass back the value from the previous form. Is the format I use correct to pass a variable inside a button in PHP?

<?php
    if (isset($_GET['id']))
    {
        $id = $_GET['id'];
        strval($id);

        echo "<a name='btn_edit' href=\"view_order.php?id='$id'\">Back</a>";
    }
?>

is this the correct format

1 Answers

Try this:

echo "<a name='btn_edit' href=\"view_order.php?id={$id}\">Back</a>";
Related