一个表单,可以只填一项也可以填多项,进行搜索。。数据库字段有id,name,auther,kind,uploader,creat_time,程序要怎么写?
<form action="" method="post" name="form1">
<h2>文献检索</h2>
<p>题名:
<input type="text" id="common"></p>
<p>作者:<input type="text" id="name"></p>
<p>类别:
<input type="text" id="kind"></p>
<p>上传者:
<input type="text" id="upload"></p>
<br/>
<input type="submit" name="Submit" value="Search">
</form>
<form action="" method="post" name="form1">
<h2>文献检索</h2>
<p>题名:
<input type="text" id="common"></p>
<p>作者:<input type="text" id="name"></p>
<p>类别:
<input type="text" id="kind"></p>
<p>上传者:
<input type="text" id="upload"></p>
<br/>
<input type="submit" name="Submit" value="Search">
</form>
if($_post["common"]){$sql="comom like %".$_post["common"]}
else if($_post["name"]){$sql="name like %".$_post["name"]}
else if($_post["kind"]){$sql="kind like %".$_post["kind"]}
else if($_post["upload"]){$sql="upload like %".$_post["upload"]}
$sql="select * from table where ".$sql;
$db->query($sql);
$sql="select * from `table_name` where name like '%标题%'";
$name=$_POST['name'];
$sql="select * from `表名` where `name` like '%".$search."%'";
执行一下这句话。
我想说不难。。加油