半点优化网 http://www.bdxc.net/
当前位置首页 > 关键词排名> 正文

PHP输入关键词后在数据库搜索并显示记录

2021-08-22 21:28:45 暂无评论 57 关键词排名 关键词   输入   数据库

加密部分:
<?php
$name=油菜;
echo /search.php?keywords=.urlencode($name);
?>
解密部分:
<?php
//$_REQUEST为PHP的预定义全局数组,可以用来获取URL中的参数值
$name=urldecode($_REQUEST($name));
?>
数据库搜索部分:
<?php
$sql=select * form table where greenKind like '%.$name.%';
$server='localhost';
$username='root';
$password='12345678';
$db='mycounter';
$conn=mysql_connect($server,$username,$password,$db);

$result=mysql_query($sql);

$row=mysql_fetch_array($result);取结果中的一行
foreach($row as $col)
echo $col;//输出每一个字段
?>

猜你喜欢