1

I am trying to create a button, and in the link use data from the row, but using the below prevents the page from loading.

Current code:

while ($row = oci_fetch_array($stid, OCI_ASSOC)) {
    echo "<tr>";
        echo "<td><code>" . $row['OrderNo'] . "</code></td>";
        echo "<td><a href='viewOrder.php?id=' . $row['OrderNo'] . ' class='btn btn-primary'>View Order</a></td>";
    echo "</tr>";
    unset($row);
}

Is there an error in the code or is it just not possible to do this?

user1978142
  • 7,946
  • 3
  • 17
  • 20
user2656114
  • 949
  • 4
  • 18
  • 35

4 Answers4

1

This line was wrong:

echo "<td><a href='viewOrder.php?id='" . $row['OrderNo'] . "' class='btn btn-primary'>View Order</a></td>";

Mistake of using " and '. Because of your comment, this one is probably that what you want:

  <?php
    while ($row = oci_fetch_array($stid, OCI_ASSOC)) {

    echo "<tr>";
        echo "<td><code>" . $row['OrderNo'] . "</code></td>";
        echo "<td><a href='viewOrder.php?id='" . $row['OrderNo'] . "'&class='btn btn-primary'>View Order</a></td>";
        echo "</tr>";
    unset($row);

    }
Xatenev
  • 6,383
  • 3
  • 18
  • 42
0

You have missused the quotes

echo "<td><a href='viewOrder.php?id=" . $row['OrderNo'] . "' class='btn btn-primary'>View Order</a></td>";
gbestard
  • 1,177
  • 13
  • 29
0

Your concatenation isn't right, the echo is surrounded by double quotes, but you try to use single quotes to break out of it.

This works:

echo '<td><a href="viewOrder.php?id=' . $row['OrderNo'] . '" class="btn btn-primary">View Order</a></td>';

For future debugging, turn errors on:

error_reporting(E_ALL);
ini_set('display_errors', '1');
MrCode
  • 63,975
  • 10
  • 90
  • 112
0

Try this

while ($row = oci_fetch_array($stid, OCI_ASSOC)) {

    echo "<tr>";
    echo "<td><code>" . $row['OrderNo'] . "</code></td>";
    echo "<td><a href='viewOrder.php?id=" . $row['OrderNo'] ."' class='btn btn-primary'>View Order</a></td>";
    echo "</tr>";
    unset($row);

  }
AVM
  • 592
  • 2
  • 11
  • 25