【php开源代码栏目提醒】:网学会员在php开源代码频道为大家收集整理了searcharticle.php提供大家参考,希望对大家有所帮助!
<?php
/*
* Created on 2006-11-20
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
include('head.php');
require_once('com/db.php');
$db = new DataAccess();
$db->connect();
if(isset($_POST['how']))
{
if($_POST['how']='按文章标题')
$field = 'title';
if($_POST['how']='按文章内容')
$field = 'content';
}
if(isset($_POST['articletype']))
{
if($_POST['articletype']==2)
$where .= " and type='0'";
if($_POST['articletype']==1)
$where .= " and type='1'";
}
if(isset($_POST['what']) and $_POST['what']<>"关键字")
$where .= " and ".$field." like '%".$_POST['what']."%'";
if($where)
$sql = "select id,title,addtime from article where 1=1".$where;
else
$sql = "select id,title,addtime from article where 1<>1";
//echo $sql;
?>
<table border="0" width="96%" cellspacing="0" cellpadding="0" id="table16" height="20">
<tr>
<td width="5%" height="18"></td>
<td width="50%" height="18" align="center"><b>标题</b></td>
<td width="20%" height="18" align="center"><b>发布时间</b></td>
</tr>
<?php
//新闻
$result = $db->query($sql);
$row_num = $db->getRowNum();
if($row_num <= 0)
echo '<tr><td width="5%" height="18"></td><td width="50%" height="18" align="center">"没有你要的结果!"</td><td width="20%" height="18" align="center"></td></tr>';
else
{
while($row = mysql_fetch_array($result,MYSQL_ASSOC))
{
?>
<tr>
<td width="5%" height="25" background="images/bg1.gif">
<p align="center">
<img border="0" src="images/new2.gif" width="11" height="11"></td>
<td width="50%" height="18" background="images/bg1.gif">
<a title=<?php echo $row['title']; ?> target="_blank" href="article.php?id=<?php echo $row['id']; ?>">
<?php echo $row['title']; ?></a></td>
<td height="25" width="20%" background="images/bg1.gif"><?php echo $row['addtime']; ?></td>
</tr>
<?php
}
}
?>
<tr>
<td height="25" colspan="3" align="center">
<p align="center">
</td>
</tr>
</table>
<?php
$db->close();
include('end.php');
?>
上一篇:
search.php
下一篇:
本科生毕业论文参考文献