我需要有关 mysql 查询的帮助。我有几个具有相同 order_id 的产品,然后想向所有人展示,但它只显示 30 种产品中的一种产品。
if (!$_GET['orderid']) {
}
else
{
$order_id = ereg_replace("[^0-9]", "", $_GET['orderid']); // filter everything but numbers for security
}
$sqlCommand = "SELECT * FROM tabell_order_product WHERE order_id='$order_id'";
$query = mysqli_query($myConnection, $sqlCommand) or die (mysqli_error());
while ($row = mysqli_fetch_array($query)) {
$product_id = $row["product_id"];
}
mysqli_free_result($query);
//---------------------------------------------------------------------------------
$sqlCommand = "SELECT * FROM tabell_product WHERE product_id='$product_id'";
$query = mysqli_query($myConnection, $sqlCommand) or die (mysqli_error());
while ($row = mysqli_fetch_array($query)) {
$model = $row["model"];
$location = $row["location"];
}
mysqli_free_result($query);
//---------------------------------------------------------------------------------
$sqlCommand = "SELECT * FROM tabell_product_description WHERE product_id='$product_id'";
$query = mysqli_query($myConnection, $sqlCommand) or die (mysqli_error());
while ($row = mysqli_fetch_array($query)) {
$name = $row["name"];
}
mysqli_free_result($query);
$output .= '<tr>
<td>' . $product_id . '</td>
<td>' . $name . '</td>
<td>' . $model . '</td>
<td>' . $location . '</td>
</tr>';?>