0
私は単純なhtml/phpスクリプトで忙しく、データベースから検索した結果をテーブル形式で表示しても何も表示されません。 は、ここに私のコードです:私は検索バーに「3」と入力PHPのテーブルに検索結果を表示するには
<html>
<head>
<title>product sales for a specific customer</title>
<link rel="stylesheet" type="text/css" href="css/style.css" />
</head>
<body>
<h3 align="center"> Please Search for a specific customer you want to see sales for: </h3>
<br />
<input type="text" name="txtNameSearch" />
<input class="src_btn" type="submit" name="btnSearch" value="Search" />
<table width="800" border="1" cellpadding="1" cellspacing="1">
<tr>
<th>Order Details Id</th>
<th>Order ID</th>
<th>Product Id</th>
<th>Login ID</th>
<th>Quantity</th>
<th>Product Price per unit</th>
<th>Product Name</th>
<th>Product Descrp</th>
<th>Genre</th>
<th>Price</th>
<th>Quantity Sold</th>
</tr>
<?php
if(isset($_POST["btnSearch"]))
{
$connection = mysqli_connect('localhost', 'root', '', 'bookstore');
$sql="SELECT * FROM order_details right join tblproduct on order_details.prod_id=tblproduct.prod_id WHERE id_login = $search";
$Joined_records=mysqli_query($connection,$sql);
if (isset($_POST['txtNameSearch'])){
$search = $_POST['txtNameSearch'];
}
while ($row=mysqli_fetch_assoc($Joined_records)){
echo"<tr>";
echo"<td>".$row["order_details_id"]."</td>";
echo"<td>".$row["order_id"]."</td>";
echo"<td>".$row["prod_id"]."</td>";
echo"<td>".$row["id_login"]."</td>";
echo"<td>".$row["quantity"]."</td>";
echo"<td>".$row["price_per_unit"]."</td>";
echo"<td>".$row["prod_name"]."</td>";
echo"<td>".$row["prod_descr"]."</td>";
echo"<td>".$row["prod_cat"]."</td>";
echo"<td>".$row["prod_price"]."</td>";
echo"<td>".$row["prod_quan"]."</td>";
echo"</tr>";
}
}
?>
</body>
</html>
だから私はやりたいインスタンスのためのものであり、私はで表示する私のデータベースに私はその3に対応するすべての値をしたい提出クリックテーブル形式。
POSTから検索値を取得する前に、SQLインジェクションBTWの影響を受けやすいクエリを実行しています。 –
@MattS私はそれを試みましたが、それでもうまくいきません。 –
@MoeJoe Mattが言っていることは、あなたがデータベースの検索を終えた後、あなたがあなたの '$ search'変数に値を割り当てているということです。それは逆のやり方です。 –