在表中使用按钮 - PHP

Mal*_*arp 3 html php html-table button

我正在按照我所拥有的书中的教程进行操作,但想向表中添加一些额外的列。我添加了“买入”和“卖出”列,并且在每个列中我想显示一个按钮。我不确定如何做到这一点,这可能吗?

这是带有表格的页面中的代码:

<?php // Example 21-9: members.php
include_once 'header.php';

if (!$loggedin) die();

echo "<div class='main'>";

$con=mysqli_connect("localhost","root","usbw","stocktrading");
// Check connection
if (mysqli_connect_errno()) {
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$result = mysqli_query($con,"SELECT * FROM stocks");

echo "<table border='1  '>
<tr>
<th>ID</th>
<th>Name</th>
<th>Price</th>
<th>Buy</th>
<th>Sell</th>
</tr>";

while($row = mysqli_fetch_array($result)) {
    echo "<tr>";
    echo "<td>" . $row['id'] . "</td>";
    echo "<td>" . $row['name'] . "</td>";
    echo "<td>" . $row['price'] . "</td>";
    echo "</tr>";
}
echo "</table>";

mysqli_close($con);
?>
Run Code Online (Sandbox Code Playgroud)

brb*_*ing 5

  echo "<tr>";
  echo "<td>" . $row['id'] . "</td>";
  echo "<td>" . $row['name'] . "</td>";
  echo "<td>" . $row['price'] . "</td>";
  echo "<td><input type='radio' name='buysell' value='buy'></td>";
  echo "<td><input type='radio' name='buysell' value='sell'></td>";
  echo "</tr>";
Run Code Online (Sandbox Code Playgroud)

像这样的东西会添加单选按钮。如果您愿意,可以使用复选框或其他类型的按钮。