success.php

代码
<?php
session_start();
if(isset($_COOKIE['iscookie']) and isset($_COOKIE['name']))
      {    
        
if($_COOKIE['name']!="")
            {
                
$_SESSION['issession']=true;
                
$_SESSION['name']=$_COOKIE['name'];
            }

    }

if($_SESSION["issession"]!=true)
{
echo "<a href=login.php>重新登录</a>";
exit;

}
$link = mysql_connect("localhost:3306","student","123456");
mysql_select_db('test');

$query = "select * from tieba";

?>
<html>

<head>
<title>程序员贴吧</title>
<style type="text/css">
<!--
.title{
    color
:#FFF;
    background-color:#06F;
    text-align:center;
}
.td{
    background
-color:#ccc;
}
-->
</style>

<body>
<div align="center">
 
<table width="603" border="1">
 
<tr class="title">
    
<td width="39">姓名</td>
    
<td width="441">标题</td>
     
<td width="441">内容</td>
    
<td width="101">时间</td>
</tr> 
<?php
$result = mysql_query($query);
$row=mysql_num_rows($result);

if($row>0)


    
$i=0;
    
while($row=mysql_fetch_array($result,MYSQL_ASSOC))
         {
    
if($i==0)
         {
    
echo "<tr class=\"td\">";
    
$i++;
    }
    
else
    {
echo "<tr>";
    
$i=0;
    }
    
?>    
        
          
<td><a href="show.php?id=<?=$row['id']?>"><?=$row["tname"]?></a></td>
         
<td><a href="show.php?id=<?=$row['id']?>"><?=$row["ttitle"]?></a></td>

          
<td><a href="show.php?id=<?=$row['id']?>"><?=$row["tword"]?></a></td>
        
<td><a href="show.php?id=<?=$row['id']?>"><?=$row["ttime"]?></a></td>
               
<?php
        }
}
else
{
echo "数据库中没有数据";
}
echo "<a href=fatie.php>发帖</a>";
mysql_close();
?>
</table>
</div>
</body>

</html>


posted @ 2010-11-13 11:23  xiao.ji  阅读(205)  评论(0编辑  收藏  举报