最后一步就是显示了。
下面这个程序要通过参数来调用。
比如php.php?jpg=jpg
后面的jpg是表格名。记住一定要的呀,不然就不能运行了,会显示程序出错。
大家可以把下面这个程序改一下。这样就可以更加美观了。
以下是源程序:
<html>
<head><title>显示</title>
</head>
<body>
<?
mysql_connect("localhost","用户名","密码")ordie("无法联接数据库!");
$query="SELECTid,url,mess,fromx,url1,mess1,fromx1,url2,mess2,fromx2,url3,mess3,fromx3from$jpg";
$result=mysql_db_query("elong",$query);//执行查询
$num=mysql_numrows($result);
$page=round($page);
$pagesize=4;
if($page==0){
$page=1;}
else{
$page=$page;}
$pagecount=($num)/$pagesize;
$pagecount=ceil($pagecount);
?>
<?if($page!=1and$num!=0){
printf("<ahref="%s?page=%s&jpg=$jpg">首页</a>",$PHP_SELF,1);
printf("<ahref="%s?page=%s&jpg=$jpg">前页</a>",$PHP_SELF,$page-1);
}else{
?>首页前页<?
}
?>
</font>
<?if($page!=$pagecountand$num!=0){
printf("<ahref="%s?page=%s&jpg=$jpg">后页</a>",$PHP_SELF,$page+1);
printf("<ahref="%s?page=%s&jpg=$jpg">尾页</a>",$PHP_SELF,$pagecount);
}else{?>后页尾页<?}?>页次:<strong><?echo$page?></strong>/<strong><?echo$pagecount?></strong>页
</span></td>
<?
if($num<>0){
$pp=0;
for($ipage=0;$ipage<$pagesize;$ipage++){
$i=($page-1)*$pagesize+$ipage;
if($i<$num){
$id=mysql_result($result,$i,"id");
$url=mysql_result($result,$i,"url");
$mess=mysql_result($result,$i,"mess");
$fromx=mysql_result($result,$i,"fromx");
$url1=mysql_result($result,$i,"url1");
$mess1=mysql_result($result,$i,"mess1");
$fromx1=mysql_result($result,$i,"fromx1");
$url2=mysql_result($result,$i,"url2");
$mess2=mysql_result($result,$i,"mess2");
$fromx2=mysql_result($result,$i,"fromx2");
$url3=mysql_result($result,$i,"url3");
$mess3=mysql_result($result,$i,"mess3");
$fromx3=mysql_result($result,$i,"fromx3");
$pp=$pp+1;
?>
<tablewidth="668"border="2"cellspacing="0"cellpadding="0"align="center"bordercolor="#FFFFFF">
<tr>
<tdwidth="167"height="127"><ahref="<?echo$url?>"target="_blank"><IMGborder=0src="<?echo$mess?>"width="160"height="120"border="4"></td>
<tdwidth="167"height="127"><ahref="<?echo$url1?>"target="_blank"><IMGborder=0src="<?echo$mess1?>"width="160"height="120"border="4"></td>
<tdwidth="167"height="127"><ahref="<?echo$url2?>"target="_blank"><IMGborder=0src="<?echo$mess2?>"width="160"height="120"border="4"></td>
<tdwidth="167"height="127"><ahref="<?echo$url3?>"target="_blank"><IMGborder=0src="<?echo$mess3?>"width="160"height="120"border="4"></td>
</tr>
</table>
<?
}
}
}
?>
<tdnowrapalign=center><spanclass=smallFont><spanclass=titleFont>分页</span>
<fontcolor=darkgray><?if($page!=1and$num!=0){
printf("<ahref="%s?page=%s&jpg=$jpg">首页</a>",$PHP_SELF,1);
printf("<ahref="%s?page=%s&jpg=$jpg">前页</a>",$PHP_SELF,$page-1);
}else{
?>首页前页<?}?></font><?if($page!=$pagecountand$num!=0){
printf("<ahref="%s?page=%s&jpg=$jpg">后页</a>",$PHP_SELF,$page+1);
printf("<ahref="%s?page=%s&jpg=$jpg">尾页</a>",$PHP_SELF,$pagecount);
}else{?>后页尾页<?}?>页次:<strong><?echo$page?></strong>/<strong><?echo$pagecount?></strong>页
</span></td>
</TABLE></DIV></CENTER>
</BODY></HTML>