其实我也不大会解释啦,就是在一个页面的一个区中插入一段代码,而这段代码是独立的,此代码与数据库有密切关系,代码如下
<?php
//get the top 6
mysql_query("set names 'GBK'");
$query = mysql_query("SELECt * FROM `guilds` ORDER BY `GP` DESC ");
//rank= 0 for ranking numbers
$rank = "0";
//start ing the table before the loop
?>
<table width="535" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="images/welcome.gif" width="485" height="43" border="0" usemap="#Map" />
<map name="Map" id="Map">
<area shape="rect" coords="427,9,475,26" href="main.php?page=view&id=1" />
</map></td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="5" cellpadding="0">
<tr>
<td><?
mysql_query("set names 'gbk'");
$query = "Select COUNT(*) FROM news";
$result = mysql_query($query);
$num = mysql_num_rows($result);
$page_count = ceil($num/$page_size);
//$offset = ($page_count-1)*$page_size;
if(empty($_GET['page']))
{
$page = 1;
}else
{
$page = $_GET['page'];
if($page<=0)
{
$page = 1;
}else
{
$page >= $page_count;
$page = $page_count-1;
}
}
$query ="Select * FROM `news` orDER BY `id` DESC LIMIT ".($page-1)*$page_count.","."$page_size";
$result = mysql_query($query);
?>
<table width="559" border="0" align="left" cellpadding="0" cellspacing="2">
<?php
while($l_result = mysql_fetch_array($result))
{
?>
<tr>
<td width="43"><div align="center">
<?php
if (($l_result['lx'] == "xitong")){ echo ("<img src='images/66.gif'>");}
elseif (($l_result['lx'] == "gengxin")){ echo ("<img src='images/67.gif'>");}
elseif (($l_result['lx'] == "zhongyao")){ echo ("<img src='images/68.gif'>");}
elseif (($l_result['lx'] == "bagua")){ echo ("<img src='images/73.gif'>");}
elseif (($l_result['lx'] == "ceshi")){ echo ("<img src='images/70.gif'>");}
elseif (($l_result['lx'] == "huodong")) { echo ("<img src='images/72.gif'>");}
?>
</div></td>
<td width="307" align="left"><div align="center"><a href="<?php echo "?page=view&id"."=".$l_result['id'];?>"><?php echo $l_result['title'];?></a><a href="<?php echo "?page=view&id"."=".$l_result['id'];?>"></a></div></td>
<td width="300" align="left"><div align="left"><a href="<?php echo "?page=view&id"."=".$l_result['id'];?>"></a><a href="<?php echo "?page=view&id"."=".$l_result['id'];?>"></a><a href="<?php echo "?page=view&id"."=".$l_result['id'];?>"><?php echo $l_result['p_time'];?></a></div></td>
</tr>
<?php
}
?>