Home > Backend Development > PHP Tutorial > PHP新手有关问题:首次进页面select全部数据,点击条件后按条件select数据库数据

PHP新手有关问题:首次进页面select全部数据,点击条件后按条件select数据库数据

WBOY
Release: 2016-06-13 12:16:23
Original
942 people have browsed it

PHP新手问题:首次进页面select全部数据,点击条件后按条件select数据库数据
各位 新人请教个问题,我想做个页面,进去第一次的时候加载的是所有的数据库,然后点下菜单,重新加载原来的页面,但是传个条件给原来的查询语句,加载显示按条件筛选的数据,怎么做啊。
------解决思路----------------------

<br /><?php<br />$where="where 1=1";<br />if(isset($_POST['seach']))<br />{<br />	if(!empty($_POST['name'])) $where.=" and name='$_POST[name]'";<br />	if(!empty($_POST['age'])) $where.=" and age='$_POST[age]'";<br />}<br />$sql="select * from table {$where}";<br />echo $sql;<br />?><br /><form action="" method="post"><br /><input type="text" name="name" value="" /><br /><input type="text" name="age" value="" /><br /><input type="submit" name="seach" value="seach" /><br /></form><br />
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template