gpt4 book ai didi

php - 在mysql中执行两个php变量where查询

转载 作者:行者123 更新时间:2023-11-29 14:31:36 25 4
gpt4 key购买 nike

我的 html 表单 ->

<form action="where.php" method="post">
<h2 align="center" style="color: white;"> Search Challan </h2>
<table border="1" bgcolor="grey" align="center">
<tr>
<td align="center"> Search a Challan Details . Enter the Challan no below :</td>
</tr>
<tr>
<td align="center">
</tr>
<tr>
<td align="center"><input type="submit" name="submit" value="Search"align="middle" ></td>
<tr>
<td>
<select name="squery" style="width:142px;" >
<option value="challan_no">Challan no </option>
<option value="product_name">Product Name</option>
<option value="Buyer">buyer</option>
<option value="Employee Responsible">Employee</option>
</td>
</tr>
<tr>
<td>
<input type="text" name="search" >
</td>
</tr>
</tr>
</form>

where.php ->

<?php
$dbhost='localhost';
$dbusername='root';
$dbuserpass='';
$dbname='inventory';

//connect to the mysql database server.
$con = mysql_connect ($dbhost, $dbusername, $dbuserpass);

if (!$con ) die ("unable to connect : ". mysql_error());

mysql_selectdb("$dbname",$con ) ;

$user_req = $_REQUEST['squery'] ; //colomn name
$req_id = $_REQUEST['search'] ; //

$query = "SELECT * FROM challan WHERE '$user_req' = $req_id ";
$result = mysql_query($query);
if (!$result) die ("DAtabase acces faild bc : ". mysql_error());

$rows = mysql_numrows($result);

for ($j=0 ; $j < $rows ; ++$j)
{
$row = mysql_fetch_row($result);

echo "<TABLE border=1 bgcolor=grey align=center width=500px float=left>" ;
echo "<tr>";
echo "<td align=center>Challan no : </td>";
echo " <td> $row[0] </td>";
echo " </tr>";
echo "<tr>";
echo "<td align=center>Challan Date : </td>";
echo " <td> $row[1] </td>";
echo "<tr>";
echo "<td align=center>Product Name : </td> ";
echo " <td> $row[2] </td>";
echo "<tr>";
echo "<td align=center>Product qty : </td> " ;
echo " <td> $row[3] </td>";
echo "<tr>";
echo "<td align=center> Buyer : </td> " ;
echo " <td> $row[4] </td>";
echo "<tr>";
echo "<td align=center>Employee Responsible : </td> " ;
echo " <td> $row[5] </td>";
echo "</tr>";
}
?>

它的输出只是空白。我无法确定我哪里出了问题。

最佳答案

空白屏幕表示发生了 fatal error ,并且 php 无法继续执行脚本,您可以在脚本顶部运行此命令,以将错误作为输出的一部分打印到屏幕上。

<?php
ini_set('display_errors', 1);

关于php - 在mysql中执行两个php变量where查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9914461/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com