main.php源代码分析

 

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

<?php 

include("conn/conn.php");

%包含数据库连接文件

?>

<table width="563" height="587" border="0" cellpadding="0" cellspacing="0">

  <tr>

    <td width="563" height="587" valign="top" bgcolor="#FFFFFF"><table width="563" border="0" cellspacing="0" cellpadding="0">

      <tr>

        <td width="563" height="27" background="Images/fufei.gif">&nbsp;</td>

      </tr>

      <tr>

        <td height="96" align="center" valign="top"><br>

          <?php

$date1=date("Y-m-d");

%获取当前时间

$sgsql=mysql_query("select * from tb_leaguerinfo  where type='公寓信息' and showday>='$date1' and checkstate=1 ");

%查询信息

$sginfo=mysql_fetch_array($sgsql);

%获取结果

if($sginfo){

do{

?>

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

            <tr>

              <td height="26"><span class="style1">『公寓信息』</span><span class="style8">&nbsp;<?php echo $sginfo[title];?>&nbsp;</span><span class="style6">&nbsp;<?php echo $sginfo[edate];?></span></td>

            </tr>

            <tr>

              <td height="26">&nbsp;&nbsp;&nbsp;<span class="style5">&nbsp;<?php echo $sginfo[content];?></span></td>

            </tr>

            <tr>

              <td height="26">&nbsp;<span class="style8">联系人:<?php echo $sginfo[linkman];?>&nbsp;&nbsp;&nbsp;联系电话:<?php echo $sginfo[tel];?></span></td>

            </tr>

            <tr>

              <td height="3" background="Images/line1.gif"></td>

            </tr>

          </table>

          <?php

}while($sginfo=mysql_fetch_array($sgsql));

%展示信息

}else{

?>

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

            <tr>

              <td align="center">暂无公寓信息资源!</td>

            </tr>

          </table>

          <?php

}

?>

</td>

      </tr>

      <tr>

        <td align="center" valign="top"><table width="560" border="0" cellspacing="0" cellpadding="0">

          <tr>

            <td height="87" background="Images/guanggao.gif">&nbsp;</td>

          </tr>

        </table></td>

      </tr>

      <tr>

        <td height="27" background="Images/mian.gif">&nbsp;</td>

      </tr>

      <tr>

        <td height="140" align="center" valign="top">

<br>

<?php

$sql=mysql_query("select count(*) as total from tb_info where type='公寓信息' and checkstate=1");

%查询结果数

$info=mysql_fetch_array($sql);

%获取结果

$total=$info[total];

%存储在一个变量内

$pagesize=4;

%一页显示的个数

 if ($total<=$pagesize){

    $pagecount=1;

    %不超过4个,显示在一页

 } 

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

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

  %若总结果数不能被pagesize整除,则去商加1

}else{

 $pagecount=$total/$pagesize;

  %否则直接取商

}

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

  $page=1;

  %默认显示第一页

}else{

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

 %否则显示url中指示的页码

}

$gsql=mysql_query("select * from tb_info where type='公寓信息' and checkstate=1 order by edate desc limit ".($page-1)*$pagesize.",$pagesize");

%查询信息

$ginfo=mysql_fetch_array($gsql);

%获取结果

if($ginfo){

  do{

?>

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

            <tr>

              <td height="26"><span class="style1">『公寓信息』</span><span class="style8">&nbsp;<?php echo $ginfo[title];?>&nbsp;</span><span class="style6">&nbsp;<?php echo $ginfo[edate];?></span></td>

            </tr>

            <tr>

              <td height="26">&nbsp;&nbsp;&nbsp;<span class="style5">&nbsp;<?php echo $ginfo[content];?></span></td>

            </tr>

            <tr>

              <td height="26">&nbsp;<span class="style8">联系人:<?php echo $ginfo[linkman];?>&nbsp;&nbsp;&nbsp;联系电话:<?php echo $ginfo[tel];?></span></td>

            </tr>

            <tr>

              <td height="3" background="Images/line1.gif"></td>

            </tr>

          </table>

<?php

}while($ginfo=mysql_fetch_array($gsql));

%展示结果

?>

<table width="543" height="27" border="0" cellpadding="0" cellspacing="0">

  <tr>

    <td width="543" height="27" colspan="3" 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="index.php?page=1" title="首页"></a><a href="index.php?page=<?php echo $page-1;?>" title="前一页">

      <?php

 }

  if($pagecount<=4){

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

 ?>

      <a href="index.php?page=<?php echo $i;?>"><?php echo $i;?></a>

      <?php

    }

  }else{

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

 ?>

      <a href="index.php?page=<?php echo $i;?>"><?php echo $i;?></a>

      <?php }?>

      <a href="index.php?page=<?php echo $page-1;?>" title="后一页"></a> <a href="index.php?page=<?php echo $pagecount;?>" title="尾页"></a>

      <?php }?></td>

  </tr>

</table>

<?php

}

else{

?>

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

  <tr>

    <td align="center">暂无公寓信息资源!</td>

  </tr>

</table>

<?php

}

?>

</td>

      </tr>

    </table>

    </td>

  </tr>

</table>

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

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一个简单的网站设计的 PHP 源码: index.php ```php <!DOCTYPE html> <html> <head> <title>网站标题</title> </head> <body> <header> <h1>网站标题</h1> <nav> <ul> <li><a href="index.php">首页</a></li> <li><a href="about.php">关于我们</a></li> <li><a href="contact.php">联系我们</a></li> </ul> </nav> </header> <main> <h2>欢迎来到我们的网站</h2> <p>这是一个简单的网站设计的 PHP 源码。</p> <p>你可以在导航栏中找到关于我们和联系我们的页面。</p> </main> <footer> <p>© 2021 网站名称</p> </footer> </body> </html> ``` about.php ```php <!DOCTYPE html> <html> <head> <title>关于我们</title> </head> <body> <header> <h1>网站标题</h1> <nav> <ul> <li><a href="index.php">首页</a></li> <li><a href="about.php">关于我们</a></li> <li><a href="contact.php">联系我们</a></li> </ul> </nav> </header> <main> <h2>关于我们</h2> <p>我们是一个致力于提供优质服务的公司。</p> <p>请联系我们以获取更多信息。</p> </main> <footer> <p>© 2021 网站名称</p> </footer> </body> </html> ``` contact.php ```php <!DOCTYPE html> <html> <head> <title>联系我们</title> </head> <body> <header> <h1>网站标题</h1> <nav> <ul> <li><a href="index.php">首页</a></li> <li><a href="about.php">关于我们</a></li> <li><a href="contact.php">联系我们</a></li> </ul> </nav> </header> <main> <h2>联系我们</h2> <p>请填写以下表格以与我们联系:</p> <form action="submit.php" method="post"> <label for="name">姓名:</label> <input type="text" id="name" name="name" required><br> <label for="email">电子邮件:</label> <input type="email" id="email" name="email" required><br> <label for="message">消息:</label> <textarea id="message" name="message" required></textarea><br> <input type="submit" value="发送"> </form> </main> <footer> <p>© 2021 网站名称</p> </footer> </body> </html> ``` submit.php ```php <!DOCTYPE html> <html> <head> <title>提交成功</title> </head> <body> <header> <h1>网站标题</h1> <nav> <ul> <li><a href="index.php">首页</a></li> <li><a href="about.php">关于我们</a></li> <li><a href="contact.php">联系我们</a></li> </ul> </nav> </header> <main> <h2>提交成功</h2> <p>感谢您的消息,我们会尽快回复您。</p> </main> <footer> <p>© 2021 网站名称</p> </footer> </body> </html> ``` 这个简单的网站设计包括了一个首页、一个关于我们的页面、一个联系我们的页面和一个提交成功的页面。你可以把它们保存在同一个文件夹中,并在本地服务器上运行它们。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值