php根据数据库搜索 php筛选查询数据库

帮我写一个php的数据库搜索页面。

search.html //前台网页编写

创新互联致力于互联网品牌建设与网络营销,包括网站制作、网站设计、SEO优化、网络推广、整站优化营销策划推广、电子商务、移动互联网营销等。创新互联为不同类型的客户提供良好的互联网应用定制及解决方案,创新互联核心团队十多年专注互联网开发,积累了丰富的网站经验,为广大企业客户提供一站式企业网站建设服务,在网站建设行业内树立了良好口碑。

html

head

meta http-equiv="Content-Type"content="text/html;charset=gb2312"

title搜索/title

/head

body

form name="form" action="search.php" method="post"

input type="text" name="search_text" size="20"

input type="submit" value="搜索"

/form

/body

/html

search.php//后台处理文件

?php

$word=$_POST["search_text"];

$link=mysql_connect("localhost","root","password") or die("无法连接");

//localhost、root和password需要根据自己的实际情况来使用。

$db_selected=mysql_select_db("db_keywords",$link);

//db_keywords为要打开的数据库。

$sql="select * from keywords where word like '%$word%' order by count desc";

//keywords为要打开查询的表

$result=mysql_query($sql,$link);

while($row=mysql_fetch_row($result))

{

for($i=0;$imysql_num_fields($result);$i++)

echo "$row[$i]"." ";

echo "br";

}

?

这是最简单也是具有最基本功能的搜索页面,其他的需要自己修改和处理了。

希望对你有所帮助。

php 数据库搜索和排序同时哪里错了,排序运行不了,搜索也不行

?php

$link=mysql_connect("localhost","root","000000");//链接服务器

if(!$link){die("链接服务器失败".mysql_error());}//判断服务器链接是否成功

$db=mysql_query("use guest");//链接数据库

if(!$db){die("数据库不存在");}//判断数据库是否存在

mysql_query('set names utf8');//确认字符集为utf8(编码格式)

$order=$_GET['order'];

if($order){

$x=" order by $order desc";

}else{

$x=" order by G_ID asc";

}

$ss=$_GET['ss'];

if($ss){

$where=" where G_UserName like '%".$ss."%' or G_sex like '%".$ss."%'";

}else{

$where="";

}

$sql="select * from g_users".$where.$x; //准备查询语句

$res=mysql_query($sql); //执行语句,获取结果集

?

body

h1 align="center"数据/h1

div align="center" class="cx"

form id="form1" name="form1" method="get" action="test2.php"

input type="text" name="ss" id="ss" /

input type="submit" name="tj" id="tj" value="搜索" /

/form

/div

table width="1300"

tbody

tr

th width="60" align="center" scope="col"

a href="?order=G_UserNamess=?php echo $ss;?"G_ID/a/th

th width="151" align="center"

a href="?order=G_UserNamess=?php echo $ss;?"G_UserName /a/th

th width="70" align="center" scope="col"G_Sex/th

th width="82" align="center" scope="col"G_Face/th

th width="196" align="center" scope="col"G_Email/th

th width="72" align="center" scope="col"G_QQ/th

th width="68" align="center" scope="col"G_Url/th

th width="107" align="center" scope="col"G_Flower/th

th width="124" align="center" scope="col"G_Date/th

th width="90" align="center" scope="col"相关操作/th

/tr

?php

//遍历结果集,收取每个用户的详细信息  

while($fetch=mysql_fetch_array($res)){? 

tr

td?php echo $fetch[0]?/td

td?php echo $fetch[1]?/td

td?php echo $fetch[5]?/td

tdimg src="?php echo $fetch['G_Face']?"/td

td?php echo $fetch[7]?/td

td?php echo $fetch['G_QQ']?/td 

tda href="?php echo $fetch['G_Url']?"?php echo $fetch['G_Url']?/a/td 

td?php echo $fetch['G_Flower']?/td

td?php echo $fetch['G_Date']?/td

td?php echo '删除 重置' ?/td

/tr ?php } ?

/tbody 

/table

php mysql怎样根据数据库表中的出生日期搜索出年龄大于65岁的记录

不知道你的语句报什么错,我认为你不应该使用right来取日期里面的你、月、日,应该使用YEAR、MONTH、DAY函数

另外,你不能使用SELECT后面的别名作为WHERE的条件,必须使用数据库表的字段作为条件,你要获取65岁以上的可以使用这样:

WHERE csrqMAKEDATE(YEAR(NOW())-65, DAYOFYEAR(NOW()))

用PHP从MySQL数据库中查取指定数据

?php

$Conn = mysql_connect('localhost', 'root', 123456789) or die(mysql_error);

msql_query('SET NAMES UTF8');//数据库编码

mysql_select_db('数据库名称');

$Resl  = mysql('select id, mm from 表名称 where name = \'admin\' ') or die(mysql_error());

while ( $rs = mysql_fetch_array( $Resl ) ) {

echo 'id是:', $rs['id'], ' mm是:', $rs['mm'], 'br /';

}

本文标题:php根据数据库搜索 php筛选查询数据库
转载注明:https://www.cdcxhl.com/article0/dojocoo.html

成都网站建设公司_创新互联,为您提供微信公众号网站导航云服务器品牌网站制作域名注册微信小程序

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

成都app开发公司