dbconnect.php
<form method="post" action="a.php">
<select name="taskOption" id="cust-id" onchange="showUser(this.value)">
<?php
include 'orderSelect.php';
echo '<option>View Order</option>';
while($row = mysqli_fetch_array($result)):;?>
<option value='<?php echo $row[0]; ?>'><?php echo $row[1]; echo " ";
echo $row[2]; ?></option>
<?php endwhile; ?>
</select>
</form>
a.php只会我想显示1点的记录,而不是显示整个数据库,PHP
<?php
include 'connect.php';
$q = intval($_GET['q']);
$sql = "SELECT id, firstname, lastname,productOne, quantity, price
FROM orderlist";
$result = mysqli_query($conn, $sql);
echo "<table >
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Product</th>
<th>Quantity</th>
<th>Price</th>
<th>Total</th>
</tr>";
while($row = mysqli_fetch_array($result)) {
$tquan = $row['quantity'];
$tprice = $row['price'];
$total = $tquan * $tprice;
echo "<tr>";
echo "<td>" . $row['firstname'] . "</td>";
echo "<td>" . $row['lastname'] . "</td>";
echo "<td>" . $row['productOne'] . "</td>";
echo "<td>" . $row['quantity'] . "</td>";
echo "<td>" . $row['price'] . "</td>";
echo "<td>" . $total . "</td>";
echo "</tr>";
}
echo "</table>";
?>
我得到它的工作。 IT显示从下拉列表中选择某项内容时我想要查看的记录/用户,但问题是显示的是整个数据库数据。我只想明确所选人员的具体情况。任何想法如何解决这个问题?我会很感激。
我只是想,当我从下拉列表中
在查询结束时,可以添加“where”子句或“limit 1”。我想,事实上,你会想'where id = $ q'不是吗? – developerwjk
你可以举个例子。我没有得到你。我对此很新。干杯。 –
ie'$ sql =“SELECT id,firstname,lastname,productOne,quantity,price FROM orderlist where id = $ q”;'你应该看看使用参数化,因为这可能会打开sql注入,但我认为这是你正在寻找的基本想法。 – developerwjk