?? search.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 + -