Php 显示特定记录的详细信息
我想显示用户在搜索框中输入的特定记录的详细信息,并在用户单击按钮后将其存储到HTML表中 然而,我无法弄清楚同样的情况需要什么条件。请帮忙 我的PHP代码是:Php 显示特定记录的详细信息,php,mysql,Php,Mysql,我想显示用户在搜索框中输入的特定记录的详细信息,并在用户单击按钮后将其存储到HTML表中 然而,我无法弄清楚同样的情况需要什么条件。请帮忙 我的PHP代码是: <?php $calldetails = $_POST["call"]; $link = mysqli_connect("server_name","username","password","database_name") or die("Error: Unable
<?php
$calldetails = $_POST["call"];
$link = mysqli_connect("server_name","username","password","database_name") or die("Error: Unable to connect:". mysqli_connect_error());
if($calldetails)
{
$sql = "select * from table_name";
if($result = mysqli_query($link,$sql))
{
if(mysqli_num_rows($result)>0)
{
echo "<table class='table table-stripped table-hover table-condensed table-border'>
<tr>
<th>Mobile Number</th>
<th>Called Number</th>
<th>Date and Time of Call</th>
<th>Duration</th>
<th>Date of Last Recharge</th>
<th>Amount of Last Recharge</th>
</tr>";
while($row = mysqli_fetch_array($result, MYSQLI_ASSOC))
{
echo "<tr>";
echo "<td>" .$row["Mobile"] . "</td>";
echo "<td>" .$row["Called_Num"] . "</td>";
echo "<td>" .$row["Date_Time"] . "</td>";
echo "<td>" .$row["Duration"] . "</td>";
echo "<td>" .$row["Last_recharge"] . "</td>";
echo "<td>" .$row["Amount"] . "</td>";
echo "</tr>";
}
echo "</table>";
mysqli_free_result($result);
}
else
echo "mySQL returned an empty result set.";
}
}
?>
无论用户在搜索框中输入什么,您的查询“从表名称中选择*”
将始终返回整个表
考虑使用WHERE
子句来过滤结果。无论用户在搜索框中输入什么,您的查询“select*from table_name”
将始终返回整个表格
考虑使用WHERE
子句来过滤结果。如果执行$sql=“select*from table\u name”代码>它将返回整个表。即使用户在搜索框中未输入任何内容
在您的代码中,您将获得一些POST数据$calldetails=$\u POST[“call”]代码>。如果要显示与$calldetails相关的数据。使用WHERE
条件
示例:SELECT*FROM table\u name,其中column\u name=$calldetails
如果执行$sql=“SELECT*FROM table\u name”代码>它将返回整个表。即使用户在搜索框中未输入任何内容
在您的代码中,您将获得一些POST数据$calldetails=$\u POST[“call”]代码>。如果要显示与$calldetails相关的数据。使用WHERE
条件
示例:SELECT*FROM table\u name,其中column\u name=$calldetails
您有fire查询“SELECT*FROM table”
相反,您必须从中传递参数
搜索框从tablename中选择*,其中为“”;
假设你是从搜索框中取名字,那么就这样做吧
$name=$\u POST[“搜索框的名称”];
然后激发查询从tablename中选择*,其中name=$name;类似这样的情况您有一个fire查询“从表中选择*”
相反,您必须从中传递参数
搜索框从tablename中选择*,其中为“”;
假设你是从搜索框中取名字,那么就这样做吧
$name=$\u POST[“搜索框的名称”];
然后激发查询从tablename中选择*,其中name=$name;类似这样的情况您有一个fire查询“select*from table”,而不是必须从搜索框select*from tablename中传递参数,其中“;”;。您使用的是fire查询“select*from table”,而不是必须从搜索框select*from tablename中传递参数,其中“;”;。