1. 1. 通过表单把查询条件提交到php文件中,在文件中以post的形式得到传送过来的条件。
  2. 2. 把传过来的查询条件赋给变量。
  3. 3. 判断如果查询条件非空,则拼接查询sql。

大体如下:

1.

<form action="" method="post">
    条件搜索:<input type="text" name="s_title">
    分类搜索:<select name="s_type">
        <option value='0'>请选择</option>
        <option value='1'>国内</option>
        <option value='2'>国际</option>
        <option value='3'>军事</option>
        <option value='4'>体育</option>
        </select>
        <input type="submit" value="搜索">
</form>

2.

$title = $_POST[‘s_title’];

$type = $_POST[‘s_type’];

3.

$sqlOrg = “select * from news where”;

if($title != null){

$addTitle = “ and title like ‘%$title%’”;

$sql .= $addTitle;

}

if($type != null){

$addType = “and type = $type”;

$sql .= $addType;

}

最新文章

  1. PHPnow在win8下安装失败的解决办法
  2. linux epoll模型
  3. JAVA实现word doc docx pdf excel的在线浏览 - 仿百度文库 源码
  4. struts.xml的配置
  5. [刷题]算法竞赛入门经典(第2版) 5-12/UVa511 - Do You Know the Way to San Jose?
  6. 龙尚 U9300C wvdial 拨号上网
  7. IIS命令行静默安装脚本-python
  8. zigbee 中ZDO的理解
  9. TCP 三次握爪 四次挥手
  10. crontab架构和格式
  11. NodeJs 学习笔记(一)Wedding 项目搭建
  12. spec 文件详解
  13. CentOS7安装Java
  14. How could I create a custom windows message?
  15. POJ 3678 Katu Puzzle (经典2-Sat)
  16. MVC初级教程(二)
  17. Eclipse daemon not running. starting it now on port ***的
  18. 在Mybatis中使用连表查询的一次实际应用
  19. python 爬虫(爬取网页的img并下载)
  20. css-id选择器

热门文章

  1. 冒泡排序原理(BubbleSorted)
  2. 简单之美 | ZooKeeper应用案例
  3. 西安Uber优步司机奖励政策(1月25日~1月31日)
  4. tomcat在linux中的启动和查看相关信息
  5. 关于Optimizer_index_cost_adj参数的设置
  6. MySQL基本配置
  7. UVa11925 Generating Premutations
  8. c#调用钩子
  9. GDB调试总结__1
  10. ssl https服务 需要 php5.3以上