find_gg.php源代码分析

<script>function StorePage(){d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(keyit=window.open('http://www.365key.com/storeit.aspx?t='+escape(d.title)+'&u='+escape(d.location.href)+'&c='+escape(t),'keyit','scrollbars=no,width=475,height=575,left=75,top=20,status=no,resizable=yes'));keyit.focus();}</script>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<link href="../css/style.css" rel="stylesheet">

<?php

include("../conn/conn.php");

%包含数据库连接文件

$flag=$_POST[commend];

%获得“推荐状态”的值

if($_POST[commend]==""){

$flag=$_GET[flag];

%若没有设置“推荐状态”,flag值为默认值“为推荐”

}

if($flag=="all"){

$sql1=mysql_query("select count(*) as total from tb_advertising order by flag desc");

%flag是“全部”,则选择所有的广告

}else{

$sql1=mysql_query("select count(*) as total from tb_advertising where flag='$flag' order by flag desc");

%若不是“全部”,则选择相应的状态的广告

}

$minfo=mysql_fetch_array($sql1);

%获得结果

$total=$minfo[total];

%获得总的数据条数

$pagesize=10;

%每页显式10条

if($total<=$pagesize){

$pagecount=1;

%总数不超过10条,pagecount按1计

}

if(($total%$pagesize)!=0){

$pagecount=intval($total/$pagesize)+1;

%不能被整除,则加1

}else{

$pagecount=$total/$pagesize;

%整除则直接赋值

}

if(($_GET[page])==""){

$page=1;

%默认显式第一页

}else{

$page=intval($_GET[page]);

%否则显式相应的页

}

if($flag=="all"){

$sql=mysql_query("select * from tb_advertising order by flag desc limit ".($page-1)*$pagesize.",$pagesize");

%若是返回全部结果,则选择相应的某页

}else{

$sql=mysql_query("select * from tb_advertising where flag='$flag' order by flag desc limit ".($page-1)*$pagesize.",$pagesize");

}

$info=mysql_fetch_array($sql);

%获得结果

?>

<table width="776" border="0" cellspacing="0" cellpadding="0">

<tr>

<td height="32" background="images/right_line.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;您现在的位置:九九度供求信息网&nbsp;&gt;&nbsp;后台管理系统</td>

</tr>

<tr>

<td height="32" background="images/right_top.gif">&nbsp;</td>

</tr>

<tr>

<td height="488" align="center" valign="top" background="images/right_middle.gif"> <table width="700" border="1" cellpadding="0" cellspacing="1" bordercolor="#FFFFFF" bgcolor="#FFCC33">

<tr align="center" bgcolor="#FFCC33">

<td width="141" bgcolor="#FFCC33">广告标题</td>

<td width="291">广告内容</td>

<td width="123">发布时间</td>

<td width="64">是否推荐</td>

<td width="63" height="22">操作</td>

</tr>

<?php

if($info){

do{

if($info[flag]=="1"){

$flag1="已推荐";

}else{

$flag1="未推荐";

}

?>

<tr bgcolor="#FFFFFF">

<td>&nbsp;<?php echo $info[title];?></td>

<td>&nbsp;<?php echo $info[content];?></td>

<td>&nbsp;<?php echo $info[fdate];?></td>

<td align="center" bgcolor="#FFFFFF" class="style11">&nbsp;<?php echo $flag1;?></td>

<td align="center" bgcolor="#FFFFFF"><a href="gg_ok.php?id=<?php echo $info[id];?>&flag=<?php echo $flag; ?>">推荐</a>/<a href="del_ok.php?id=<?php echo $info[id];?>&flag=<?php echo $flag; ?>">删除</a></td>

</tr>

<?php

}while($info=mysql_fetch_array($sql));

?>

<tr bgcolor="#FFFFDD">

<td height="22" colspan="8" align="right"> &nbsp; 共有&nbsp;

<?php

echo $total;

?>

&nbsp;条&nbsp;每页显示&nbsp;<?php echo $pagesize;?>&nbsp;条&nbsp;第&nbsp;<?php echo $page;?>&nbsp;页/共&nbsp;<?php echo $pagecount; ?>&nbsp;页

<?php

if($page>=2){

?>

<a href="find_gg.php?flag=<?php echo $flag;?>&page=1" title="首页"></a> <a href="find_gg.php?flag=<?php echo $flag;?>&page=<?php echo $page-1;?>" title="上一页"></a>

<?php

}

if($pagecount<=4){

for($i=1;$i<=$pagecount;$i++){

?>

<a href="find_gg.php?flag=<?php echo $flag;?>&page=<?php echo $i;?>"><?php echo $i;?></a>

<?php

}

}else{

for($i=1;$i<=4;$i++){

?>

<a href="find_gg.php?flag=<?php echo $flag;?>&page=<?php echo $i;?>"><?php echo $i;?></a>

<?php }?>

<a href="find_gg.php?flag=<?php echo $flag;?>&page=<?php echo $page-1;?>" title="下一页"></a> <a href="find_gg.php?flag=<?php echo $flag;?>&page=<?php echo $pagecount;?>" title="尾页"></a>

<?php }?>

&nbsp;</td>

</tr>

<?php

}else{

?>

<tr align="center" bgcolor="#FFFFFF">

<td colspan="8">对不起,您检索的信息不存在!</td>

</tr>

<?php

}

?>

</table></td>

</tr>

<tr>

<td height="32" background="images/right_bottom.gif">&nbsp;</td>

</tr>

</table>

你可能感兴趣的:(sql,PHP,mysql,css)