-1

I have code like this which is a button for a user to be redirected to the auction page for a specific item with a specific auction_id. The button is of type <button> and I am trying to give it an onclick to redirect to:

http://192.168.33.10/productpage.php?q=12344

But instead my current code makes the page redirect to:

http://192.168.33.10/productpage.php?q=%3C?php%20echo%20$id;%20?%3E

Any ideas why? Code is below, I used solutions online but none help for the <button> tag.

<td class="col-sm-1 col-md-1">
                            <?php
                            if ($_SESSION['role_id'] == 1 && $enddt > time()) {
                                $id = $bidauction['auction_id'];
                                echo '<button type="button" onclick="location.href=\'productpage.php?q=<?php echo $id; ?>\'" class="btn btn-success" style="margin-top:10px">
                                <span class="glyphicon glyphicon-hand-up"></span> Raise Bid
                                </button>';
                            }
                            ?>
                        </td>
Dhruv Ghulati
  • 2,976
  • 3
  • 35
  • 51

2 Answers2

1

Try Like this:-

<td class="col-sm-1 col-md-1">
<?php
if ($_SESSION['role_id'] == 1 && $enddt > time()) {
    $id = $bidauction['auction_id'];
    echo '<a href="productpage.php?q='.$id.'" class="btn btn-success" style="margin-top:10px">
    <span class="glyphicon glyphicon-hand-up"></span> Raise Bid
    </a>';
}
?>
</td>
rahul
  • 841
  • 1
  • 8
  • 18
0

You are writing a PHP tag inside the PHP code, which I think is not necessary, insted of writing , just use

...'.$id.'...

Abhi
  • 104
  • 5