改成这样看看:echo "<html><head><title>搜索结果</title><meta http-equiv=Content-Type content=text/html; charset=gb2312><link rel=stylesheet href=data/pcpi.css></head>";
echo "<body bgcolor=#FFFFFF text=#000000 leftmargin=1 topmargin=1 marginwidth=1 marginheight=1>";
require('data/masthead.inc');
echo "<table width=760 height=420 border=0 cellspacing=0 cellpadding=0><tr><td width=150 bgcolor=6699CC valign=top>";
require('data/leftnav.inc');
echo "</td><td width=10> </td><td valign=top><p><br><b class=maintitle>Product search result</b></p><div align=right><a href=$tb/list.php>返回</a></div><hr size=1>";
echo "<h4>搜索关键词“<font color=red><b>$pn</b></font>”的结果如下:</h4>";
mysql_select_db("pcpi",$open);
$sql="select * from $tb where pn like '%$pn%'";
$result=mysql_query($sql);if(mysql_fetch_row ( resource result)){ // 此处加什么,才能够使空上if语句能正常工作。echo "<table cellpadding=3 cellspacing=1 border=0 width=450>";while ( $record = mysql_fetch_array($result) ) {
echo("<tr><td width=40>".$record["id"]."</td><td width=128>".$record["brand"]."</td><td width=109>".$record["pn"]."</td><td width=73><a href=\"$tb/update.php?action=html_update&id=$record[id] \">编辑</a> </td><td width=69> <a href=\"serchreview.php?id=$record[id]&tablename=$tb \">查看</a></td><td>");if(!$record[finalizedate]){
echo "Draft";
}
else echo "Final";
echo("</td></tr>");
}echo "</table>";}else {echo "很抱歉,没有找到 <font color=red>".$pn."</font> ,请<a href=".$tb."/index.php?pn=".$pn.">点击添加</a>";
}
echo "<p> </p></td></tr></table>";
require('data/foot.inc');
echo "</body></html>";
?>
echo "<body bgcolor=#FFFFFF text=#000000 leftmargin=1 topmargin=1 marginwidth=1 marginheight=1>";
require('data/masthead.inc');
echo "<table width=760 height=420 border=0 cellspacing=0 cellpadding=0><tr><td width=150 bgcolor=6699CC valign=top>";
require('data/leftnav.inc');
echo "</td><td width=10> </td><td valign=top><p><br><b class=maintitle>Product search result</b></p><div align=right><a href=$tb/list.php>返回</a></div><hr size=1>";
echo "<h4>搜索关键词“<font color=red><b>$pn</b></font>”的结果如下:</h4>";
mysql_select_db("pcpi",$open);
$sql="select * from $tb where pn like '%$pn%'";
$result=mysql_query($sql);if(mysql_fetch_row ( resource result)){ // 此处加什么,才能够使空上if语句能正常工作。echo "<table cellpadding=3 cellspacing=1 border=0 width=450>";while ( $record = mysql_fetch_array($result) ) {
echo("<tr><td width=40>".$record["id"]."</td><td width=128>".$record["brand"]."</td><td width=109>".$record["pn"]."</td><td width=73><a href=\"$tb/update.php?action=html_update&id=$record[id] \">编辑</a> </td><td width=69> <a href=\"serchreview.php?id=$record[id]&tablename=$tb \">查看</a></td><td>");if(!$record[finalizedate]){
echo "Draft";
}
else echo "Final";
echo("</td></tr>");
}echo "</table>";}else {echo "很抱歉,没有找到 <font color=red>".$pn."</font> ,请<a href=".$tb."/index.php?pn=".$pn.">点击添加</a>";
}
echo "<p> </p></td></tr></table>";
require('data/foot.inc');
echo "</body></html>";
?>
$sql="select * from ".$_POST['tb']." where pn like '%".$_POST['pn']."%'";
如果是GET方法传递请使用下面的
$sql="select * from ".$_GET['tb']." where pn like '%".$_GET['pn']."%'";