【发布时间】:2013-09-05 01:05:08
【问题描述】:
<?php
$button=$_GET['submit'];
$search=$_GET['search'];
if(!$search)
echo "you did not enter a HAWB.";
else
{
if(strlen($search)<=2)
echo "Search term too short";
else
echo "You searched for <b> $search </b> <hr size='1'>";
mysql_connect("localhost","root","") or die ("cannot connect");
mysql_select_db("trip");
$search_exploded=explode("",$search);
$x=0;
$construct="";
foreach($search_exploded as $search_each)
{
$x++;
if ($x==1)
$construct="keywords LIKE '%search_each%'";
else
$construct="OR keywords LIKE '%search_each%'";
}
$construct="Select * from trip where $construct";
$run=mysql_query($construct);
$foundnum=mysql_num_rows($run);
if($foundnum==0)
` echo "No results found";
else
{
echo "$foundnum results found.<p>";
while ($runrows=mysql_fetch_assoc($run);
{
echo "<table border='1'>
<tr>
<th>TYPE</th>
<th>HAWB</th>
<th>DATE</th>
<th>TIME</th>
<th>PLATE NO.</th>
<th>NO. OF PIECES</th>
<th>CARGO MARSHAL</th>
<th>BY</th>
<th>REMARKS 1</th>
<th>REMARKS 2</th>
</tr>";
echo "<tr>";
echo "<td>" . $row['Type'] . "</td>";
echo "<td>" . $row['HAWB'] . "</td>";
echo "<td>" . $row['Date'] . "</td>";
echo "<td>" . $row['Time'] . "</td>";
echo "<td>" . $row['Plate_no'] . "</td>";
echo "<td>" . $row['Pcs'] . "</td>";
echo "<td>" . $row['Cargo_Marshal'] . "</td>";
echo "<td>" . $row['By'] . "</td>";
echo "<td>" . $row['Remarks1'] . "</td>";
echo "<td>" . $row['Remarks2'] . "</td>";
echo "</tr>";
}
echo "</table>";
}
}
}
?> //code formatted
【问题讨论】:
-
在您的问题正文中添加一些文本,解释代码并发布实际的错误消息将使您的问题得到更高的评价。就目前而言,这是一个结构不佳的问题。
-
那不可读。使用代码标签
-
使用一个体面的 IDE 和语法高亮,让这个词变得更好。
-
PSA:
mysql_*函数是 deprecated in PHP 5.5。不建议编写新代码,因为它会阻止您将来升级。相反,请使用 MySQLi 或 PDO 和 be a better PHP Developer。
标签: php mysql parse-error