search
Homephp教程php手册php 数据库内容搜索(搜索指定内容并输出)

php 数据库内容搜索(搜索指定内容并输出)

Jun 13, 2016 am 10:07 AM
mysqlphpcontentprincipleaccomplishdesignationsubmitsearchdatadatabaseuserofSimplein the tableoutput

实现原理很简单就是根据用户提交的数据到mysql数据表中查询是否有相同的,有就输出没有就不操作了。这是一款简单的记录搜索代码。

php教程 数据库教程内容搜索(搜索指定内容并输出)
/*
首先我们来创建搜索数据表
create table if not exists `search` (
  `id` int(4) not null auto_increment,
  `keyword` varchar(500) not null,
  primary key  (`id`)
) engine=myisam default charset=utf8 auto_increment=1 ;

保存数据

insert into `acc`.`search` (
`id` ,
`keyword`
)
values (
null , '内容搜索'
), (
null , 'php站内搜索'
);

*/

//数据连接

$conn = mysql教程_connect('localhost','ac','1');//这里的ac用户名,1是密码,修改成你自己的mysql便可

$res = mysql_db_query('abc',"select * from search where keyword='内容搜索' ") or die(mysql_error());

if(mysql_num_rows($res) == 1) {
   while($row = mysql_fetch_assoc($res)) {
      foreach($row as $key => $val) {
         echo $row['keyword'],'
';
      }
   }
}

/*
实现原理很简单就是根据用户提交的数据到mysql数据表中查询是否有相同的,有就输出没有就不操作了。这是一款简单的记录搜索代码。
本站原创转载注明来源www.bKjia.c0m
*/

Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool