您好,欢迎访问一九零五行业门户网

javascript - 怎么实现我这个网页的查询方式?

如图所示,我的网页后台使用php实现的,我想实现没有点击查询按钮时,在下面的表格中显示数据库中的全部项目信息;单击查询后,显示符合条件的项目,目前我的显示这种,我没有设置未点击查询的情况,应该用什么写?js还是php?大体该怎么写
目前我只写了这个
mysql_select_db(wuliu, $con); $result=mysql_query(select * from content_info where title='$_post[textfield22]' and submiter='$_post[textfield322]' and area='$_post[select]' and field='$_post[select2]' and pass=0); while($row = mysql_fetch_array($result)) { echo; echo ; echo ; echo .$row['updatedate'].$row['updatetime']./*2004-10-14 10:08:01*/ ; echo .$row['area']. ; echo .$row['field']. ; echo .$row['title']. ; echo .$row['submiter']. ; echo
; } mysql_close($con);

回复内容:
如图所示,我的网页后台使用php实现的,我想实现没有点击查询按钮时,在下面的表格中显示数据库中的全部项目信息;单击查询后,显示符合条件的项目,目前我的显示这种,我没有设置未点击查询的情况,应该用什么写?js还是php?大体该怎么写
目前我只写了这个
mysql_select_db(wuliu, $con); $result=mysql_query(select * from content_info where title='$_post[textfield22]' and submiter='$_post[textfield322]' and area='$_post[select]' and field='$_post[select2]' and pass=0); while($row = mysql_fetch_array($result)) { echo; echo ; echo ; echo .$row['updatedate'].$row['updatetime']./*2004-10-14 10:08:01*/ ; echo .$row['area']. ; echo .$row['field']. ; echo .$row['title']. ; echo .$row['submiter']. ; echo
; } mysql_close($con);

判断是否有post,有post才执行查询。
if(isset($_post)){//这里是你发出来了那部分}
sql拼接有问题
将where语句分离出来。
$where = ;if(isset($_post)){ $where = where title='$_post[textfield22]' and submiter='$_post[textfield322]' and area='$_post[select]' and field='$_post[select2]' and pass=0;}$result=mysql_query(select * from content_info .$where);
强烈建议参数化查询,防止注入
http://php.net/manual/zh/clas...
思路:
1.用分页查询的方式,每一页显示 10条信息
2.get方式提交表单 拼装sql语句
3。当没有查询条件的时候,则查询全部(分页)
php和js都可以。
你报错的原因是因为你调用$_post变量错了。
$result=mysql_query(select * from content_info where title='$_post[textfield22]' and submiter='$_post[textfield322]' and area='$_post[select]' and field='$_post[select2]' and pass=0);
改为
$result=mysql_query(select * from content_info where title='.$_post['textfield322'].' and submiter='.$_post['textfield322'].' and area='.$_post['select'].' and field='.$_post['select2'].' and pass=0);
像楼上说的,最好是做个分页处理。mysql语句里面用limit去处理下。
不要这么拼接sql语句啊,分分钟搞出个sql注入出来。
建议在这个拼接语句的外部设置变量默认值,然后接收到post数据后校验并过滤后再覆盖旧默认值,再拼接查询语句吧。
这样子既安全,又解决你的需求。
1.$_post数组里面的key对应的值要给一个默认值
2.加上分页
3.好好学习,天天向上
其它类似信息

推荐信息