⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 search.php

📁 新闻发布系统
💻 PHP
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>新闻发布系统</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2313">
</head>
<body leftmargin="0" topmargin="0">
<form name="form1" method="post" action="">
<font size="2">
<center>
<table border="0" width="90%">
<tr>
<td colspan="2" bgcolor="#FF9966"><div align="center"><font color="#CC0033" size=6><strong>新闻搜索</strong></font></div></td>
</tr>
<tr>
<td width="46%"><div align="right">新闻标题关键字:</div></td>
<td width="54%"><input name="search" type="text" id="search"></td>
</tr>
<tr>
<td height="41" colspan="2">  <div align="center">
  <div align="center">
    <input type="submit" name="Submit" value="搜索">   
 <a href="http://localhost/news/admin/index.php"> 返回</a></div></td>
</tr>
<tr>
<td colspan="2" align="center"><?
			//包含一个配置文件
			include("admin/config.php");
			//获取表单查询字符串
			$userquery = $_POST['search'];
			//判断查询的字符串是否为空
			if ($userquery == "") {
				echo "<font color=red size=2>请输入要搜索新闻的标题!</font>";
			} else { 
				//链接数据库
				$link = mysql_connect($sqlhost ,$sqluser,$sqlpass);
				//判断是否链接
				if (! $link)
					die("不能链接数据库服务器");
					//选择数据库
				mysql_select_db($sqldb) or die("不能选择数据库?");		
				//定义查询语句
				$query = mysql_query("SELECT * FROM fubonews WHERE subject LIKE '%$userquery%'");
				//输出查询关键字
				echo "查询关键字是:<font color=red> $userquery</font><BR>";
				//将查询的数据保存到一个数组中
				while($row = mysql_fetch_array($query)) {
				$foundtitle = $row["subdect"];
		?>
  </td>
</tr>
</table>
</center>
</font>
</form>
<table width="100%">
<tr>
<td width="925" height="38" colspan="2" align="center"><table width="90%" border="1" cellpadding="0" cellspacing="0" bordercolor="#FF9966">
  <tr>
    <td width="10%" bgcolor="#FF9966"><font size="2">新闻标题</font></td>
    <td bgcolor="#FF9966"><font size="2"><? echo "" . $row["subject"] . ""; ?></font></td>
  </tr>
  <tr>
    <td width="10%"><font size="2">新闻内容</font></td>
    <td><font size="2"><? echo "" . $row["news"] . ""; ?></font></td>
  </tr>
  <tr>
    <td width="10%"><font size="2">发布时间</font></td>
    <td><font size="2"><? echo "" . $row["datetime"] . ""; ?></font></td>
  </tr>
</table>
    <?			
				mysql_close($link);
			}
		}
	?>
    <? include("admin/footer.php"); ?>
 </td>
</tr>
</table>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -