<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<script language="javascript教程">
check111cnNet()
{
var keyword = myfm.keyword.value;
if( keyword =='' )
{
alert('www.111cn.net提示你:请输入要查询的内容');
return false;
}
}
</script>
</head>
<body>
<form id="myfm" name="myfm" method="post" action="">
<label>
输入查询关键字:
<input type="text" name="keyword" />
</label>
<label>
<input type="submit" name="Submit" value="提交" onClick="return check111cnNet();" />
</label>
</form>
</body>
</html>
<?php
// 创建数据库教程连接
mysql教程_connect('localhost','111cn.net','www.111cn.net');
mysql_select_db('www.111cn.net');//数据库选择
mysql_query('set names "gbk"');
//进度查询操作
if($_POST)
{
$keyword = $_POST['keyword'];
$sql = "Select * from search where title like '%$keyword%' limit(www.111cn.net) 0,10";
$query = mysql_query($sql ) or die("www.111cn.net提示你:查询出错了");
if( mysql_num_rows( $query ) )
{
while( $rs = mysql_fetch_array( $query ) )
{
echo $rs['title'];
}
}
else
{
echo '没有要找的内容';
}
}
/*
数据表结构
CREATE TABLE `111cnNet`.`test` (
`id` INT( 8 ) NOT NULL AUTO_INCREMENT ,
`title` CHAR( 150 ) NULL ,
`content` TEXT NULL ,
PRIMARY KEY ( `id` )
) ENGINE
*/
//函数解析
mysql_connect //数据库连接了有三个参数分别为 数据库服务器名称,用户名,密码
mysql_select_db//参数有二个,第二个可选 ,第一个数据库名称,第二个数据库连接$connwww.111cn.net
mysql_query('set names "gbk"'); //这一句比较重要,就是设置读取数据库内容的编码了,这句要设置与文档编辑一致,否则可能出现乱码。
mysql_query //数据查询,有二个参数,第一个必须,为sql查询语句。
mysql_num_rows //统计mysql_query查询记录多少条,返回为int型
mysql_fetch_array //读取当前记录集一条记录保存到数组。
$_POST
if else
while
// 纯本站原创转载必须注明来源否则必究责任 来源http://www.111cn.net/phper/php.html
?>
from:http://www.111cn.net/phper/21/7e83afe990d0cda097dbd33aa94b5c2f.htm
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<script language="javascript教程">
check111cnNet()
{
var keyword = myfm.keyword.value;
if( keyword =='' )
{
alert('www.111cn.net提示你:请输入要查询的内容');
return false;
}
}
</script>
</head>
<body>
<form id="myfm" name="myfm" method="post" action="">
<label>
输入查询关键字:
<input type="text" name="keyword" />
</label>
<label>
<input type="submit" name="Submit" value="提交" onClick="return check111cnNet();" />
</label>
</form>
</body>
</html>
<?php
// 创建数据库教程连接
mysql教程_connect('localhost','111cn.net','www.111cn.net');
mysql_select_db('www.111cn.net');//数据库选择
mysql_query('set names "gbk"');
//进度查询操作
if($_POST)
{
$keyword = $_POST['keyword'];
$sql = "Select * from search where title like '%$keyword%' limit(www.111cn.net) 0,10";
$query = mysql_query($sql ) or die("www.111cn.net提示你:查询出错了");
if( mysql_num_rows( $query ) )
{
while( $rs = mysql_fetch_array( $query ) )
{
echo $rs['title'];
}
}
else
{
echo '没有要找的内容';
}
}
/*
数据表结构
CREATE TABLE `111cnNet`.`test` (
`id` INT( 8 ) NOT NULL AUTO_INCREMENT ,
`title` CHAR( 150 ) NULL ,
`content` TEXT NULL ,
PRIMARY KEY ( `id` )
) ENGINE
*/
//函数解析
mysql_connect //数据库连接了有三个参数分别为 数据库服务器名称,用户名,密码
mysql_select_db//参数有二个,第二个可选 ,第一个数据库名称,第二个数据库连接$connwww.111cn.net
mysql_query('set names "gbk"'); //这一句比较重要,就是设置读取数据库内容的编码了,这句要设置与文档编辑一致,否则可能出现乱码。
mysql_query //数据查询,有二个参数,第一个必须,为sql查询语句。
mysql_num_rows //统计mysql_query查询记录多少条,返回为int型
mysql_fetch_array //读取当前记录集一条记录保存到数组。
$_POST
if else
while
// 纯本站原创转载必须注明来源否则必究责任 来源http://www.111cn.net/phper/php.html
?>
from:http://www.111cn.net/phper/21/7e83afe990d0cda097dbd33aa94b5c2f.htm