0
我的HTML表單 - >在MySQL執行兩個PHP變量,其中查詢
<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>";
}
?>
其輸出僅僅是空白。我無法確定我出錯的地方。
請清理你的代碼有點您在這裏發佈之前... – evotopid 2012-03-28 19:37:47
一個空白頁通常意味着有PHP中的致命錯誤,你沒有錯誤報告開啓。嘗試把這個在你的腳本的開頭:'的ini_set( 「display_errors設置」,1);'之後'的error_reporting(E_ALL);其中 '$ user_req'= $ req_id'你使用' – octern 2012-03-28 19:39:20
在查詢'SELECT * FROM challan列名稱的撇號。使用這個:'SELECT * FROM challan其中$ user_req =「$ req_id'' – Tom 2012-03-28 19:40:50