解决方案 »
- Programmer and co-founder needed(PHP)-北京
- 织梦模板的路径配置文件在哪
- 将excel数据导入到Access中
- PHP在IIS6下运行会出现" HTTP 服务器终止了该脚本"请大家帮着看看。
- ZxPhpLib v0.3发布 大大简化Web项目开发
- 显示问题
- 匹配中的变量引用:eregi_replace("(<a href='任意字符'>)", "<a href='".rawurlencode("任意字符")."'>")
- 怎么样才能用php函数system运行linux命令?
- PHP目录里.htaccess 重定向到一个文件
- 如何通过判断搜索引擎来路进行跳转--希望大神指点代码
- 处理一个二维数组的问题
- 求教:以前用php编程 现在要换 好不好
混杂在一起 连你自己都不知道get执行啥 post访问时执行啥吧标题为啥要突出你是mm?你有贴照片的打算吗
<?php
if($_POST["submit2"]=="查询")
{
$txt_book=$_POST["text_book"];
$sql = mysql_query("select * from tb_student2 where bookname '%".trim($txt_book)."%'",$connID);
$info = mysql_fetch_object($sql); echo "<table align=\"center\" width=\"600\" border=\"1\"><tr>";
while($info= mysql_fetch_object($sql))
{
echo "<td>".$info->id."</td><td>".$info->bookname."</td><td>".$info->time."</td><td>".$info->price."</td><td>".$info->author."</td><td>".$info->press."</td></table>";
}
}//if end
?>
这这么错误?猪头920
这只是一个Warning信息,可以通过设置error_reporting(E_ALL ^ E_NOTICE);来屏蔽这个信息,但是如果想代码严谨的话,可以使用下面的方法isset判断:
<?php
$host="127.0.0.1";
$userName="root";
$password="";
$dbName="test01";
$connID=mysql_connect($host,$userName,$password);
mysql_select_db($dbName,$connID);
mysql_query("set names gbk");
?>
<form name="form1" action="$_SERVER['PHP_SELF']" method="post">
<p>
<label>请输入图书的名称</label>
<input type="text" size="20" name="text_book">
<input type="submit" name="submit2" value="查询">
</p>
</form>
<?php
if(isset($_POST["submit2"]) && $_POST["submit2"] == "查询"){
$txt_book=$_POST["text_book"];
$sql = mysql_query("select * from tb_student2 where bookname like '%".trim($txt_book)."%'",$connID);
$info = mysql_fetch_object($sql);}
echo "<table align=\"center\" width=\"600\" border=\"1\"><tr>";
while($info= mysql_fetch_object($sql)){
echo "<td>".$info->id."</td><td>".$info->bookname."</td><td>".$info->time."</td><td>".$info->price."</td><td>".$info->author."</td><td>".$info->press."</td></table>";
}
?>
<?php
if(isset($_POST["submit2"]) && $_POST["submit2"] == "查询"){
$txt_book=$_POST["text_book"];
$sql = mysql_query("select * from tb_student2 where bookname like '%".trim($txt_book)."%'",$connID);
$info = mysql_fetch_object($sql);//这里是多余的}
echo "<table align=\"center\" width=\"600\" border=\"1\"><tr>";
while($info= mysql_fetch_object($sql)){
echo "<td>".$info->id."</td><td>".$info->bookname."</td><td>".$info->time."</td><td>".$info->price."</td><td>".$info->author."</td><td>".$info->press."</td></table>";
}
?>
lz貌似修改了帖子