存档

文章标签 ‘源代码’

在朋友哪里搞到的qq天气预报代码

2007年12月2日 渴慕晨光 1 条评论

在朋友哪里能到的很简单的qq天气预报小偷程序,呵呵其实很简单啊!

<center>
<?php
$no = $_REQUEST['no'];
if ($no == '') $no = 125;
$f=file('http://weather.news.qq.com/inc/ss'.$no.'.htm');//改一下这网址
foreach ($f as $line_num => $line) {
    //echo "Line #<b>{$line_num}</b> : " . htmlspecialchars($line) . "<br />n";
}
$fee = strip_tags("$f[13] $f[14] $f[18] $f[24] $f[30] $f[35]");
$fe = explode(" ","$fee");
//echo str_replace("n",'',$fee);
?>

 <style type="text/css">
body,table{font-size:12px;line-height:150%;}
A.color4:link {COLOR: #DD7D02;TEXT-DECORATION: none}
A.color4:visited { COLOR: #DD7D02;TEXT-DECORATION: none}
A.color4:active { COLOR: #DD7D02;TEXT-DECORATION: underline}
A.color4:hover { COLOR: #DD7D02;TEXT-DECORATION: underline}
</style>
<?=$fe[0];?> <?=$fe[1];?> <?=$fe[2];?>
<script>
function getredirects(v) {
 if (v=='') v=123;
 window.location.href='/index/weather.php?no='+v;
}
</script>
        <select name="select" id="obSelect" onChange="getredirects(this.value)">
          <option <? if($no==125){ print 'selected="selected"';} ?> value="125">北京</option>
          <option <? if($no==292){ print 'selected="selected"';} ?>  value="292">广州</option>
          <option <? if($no==252){ print 'selected="selected"';} ?>  value="252">上海</option>
          <option <? if($no==127){ print 'selected="selected"';} ?>  value="127">天津</option>
          <option <? if($no==212){ print 'selected="selected"';} ?>  value="212">重庆</option>
          <option <? if($no==115){ print 'selected="selected"';} ?>  value="115">沈阳</option>
          <option <? if($no==244){ print 'selected="selected"';} ?>  value="244">南京</option>
          <option <? if($no==211){ print 'selected="selected"';} ?>  value="211">武汉</option>
          <option <? if($no==166){ print 'selected="selected"';} ?>  value="166">成都</option>
          <option <? if($no==186){ print 'selected="selected"';} ?>  value="186">西安</option>
          <option <? if($no==82){ print 'selected="selected"';} ?>  value="82">石家庄</option>
          <option <? if($no==84){ print 'selected="selected"';} ?>  value="84">太原</option>
          <option <? if($no==189){ print 'selected="selected"';} ?>  value="189">郑州</option>
          <option <? if($no==103){ print 'selected="selected"';} ?>  value="103">长春</option>
          <option <? if($no==17){ print 'selected="selected"';} ?>  value="17">哈尔滨</option>
          <option <? if($no==69){ print 'selected="selected"';} ?>  value="69">呼和浩特</option>
          <option <? if($no==140){ print 'selected="selected"';} ?>  value="140">济南</option>
          <option <? if($no==248){ print 'selected="selected"';} ?>  value="248">合肥</option>
          <option <? if($no==255){ print 'selected="selected"';} ?>  value="255">杭州</option>
          <option <? if($no==276){ print 'selected="selected"';} ?>  value="276">福州</option>
          <option <? if($no==287){ print 'selected="selected"';} ?>  value="287">厦门</option>
          <option <? if($no==218){ print 'selected="selected"';} ?>  value="218">长沙</option>
          <option <? if($no==296){ print 'selected="selected"';} ?>  value="296">深圳</option>
          <option <? if($no==295){ print 'selected="selected"';} ?>  value="295">南宁</option>
          <option <? if($no==232){ print 'selected="selected"';} ?>  value="232">桂林</option>
          <option <? if($no==264){ print 'selected="selected"';} ?>  value="264">南昌</option>
          <option <? if($no==227){ print 'selected="selected"';} ?>  value="227">贵阳</option>
          <option <? if($no==1){ print 'selected="selected"';} ?>  value="1">香港</option>
          <option <? if($no==2){ print 'selected="selected"';} ?>  value="2">澳门</option>
          <option <? if($no==179){ print 'selected="selected"';} ?>  value="179">昆明</option>
          <option <? if($no==280){ print 'selected="selected"';} ?>  value="280">台北</option>
          <option <? if($no==150){ print 'selected="selected"';} ?>  value="150">拉萨</option>
          <option <? if($no==303){ print 'selected="selected"';} ?>  value="303">海口</option>
          <option <? if($no==57){ print 'selected="selected"';} ?>  value="57">兰州</option>
          <option <? if($no==78){ print 'selected="selected"';} ?>  value="78">银川</option>
          <option <? if($no==56){ print 'selected="selected"';} ?>  value="56">西宁</option>
          <option <? if($no==28){ print 'selected="selected"';} ?>  value="28">乌鲁木齐</option>
        </select>
        <script>

var o=document.getElementById('obSelect');
if (v!= '') o.value=v;

  </script>
 市
</center>

分类: web编程 标签: , ,

php读取文件夹里面内容的简单源代码

2007年10月21日 渴慕晨光 2 条评论

php读取文件夹里面内容的简单源代码,上篇文章(http://www.viatop.cn/blog/show-166-1.htm)里面的那些文件名都是用这个读出来的.不过可能有些慢吧.

PHP代码
  1. <?php   
  2. // 注意在 4.0.0-RC2 之前不存在 !== 运算符   
  3.   
  4. if ($handle = opendir('./regedit')) {   
  5.     echo "Directory handle: $handle\n";   
  6.     echo "Files:\n";   
  7.   
  8.     /* 这是正确地遍历目录方法 */  
  9.     while (false !== ($file = readdir($handle))) {   
  10.         echo "$file"."<br>";   
  11.     }   
  12.   
  13.     closedir($handle);   
  14. }   
  15. ?>   
分类: web编程 标签: , , ,

IE和firefox均适用的图片轮换效果

2007年10月17日 渴慕晨光 3 条评论

要轮换的图片的位置先插入图片,文中的"$img1"等是我自己用的php变量,就是图片的网址.

XML/HTML代码
  1. <a id="javascript.a" href="#"><img id="javascript.img" style="FILTER: blendTrans(duration=2)" height="348" src="upfiles/<?=$img1?>" width="592" border="0" /></a>  

然后在下面插入以下javascript代码.

JavaScript代码
  1. <script>   
  2. <!--   
  3. var ImgSrc = new Array();//图片地址   
  4. ImgSrc[0] = "upfiles/<?=$img1?>"  
  5. ImgSrc[1] = "upfiles/<?=$img2?>"  
  6. ImgSrc[2] = "upfiles/<?=$img3?>"  
  7. ImgSrc[3] = "upfiles/<?=$img4?>"  
  8.   
  9.   
  10. for (var i=0;i<ImgSrc.length;i++){(new Image()).src = ImgSrc[i];}//预加载图片   
  11.   
  12. var ImgAlt = new Array();//鼠标放上去显示的文字   
  13. ImgAlt[0] = "main photo"  
  14. ImgAlt[1] = "main photo"  
  15. ImgAlt[2] = "main photo"  
  16. ImgAlt[3] = "main photo"  
  17.   
  18. var ImgHerf =  new Array();//链接   
  19. ImgHerf[0] = "#"  
  20. ImgHerf[1] = "#"  
  21. ImgHerf[2] = "#"  
  22. ImgHerf[3] = "#"  
  23.   
  24. var step=0;   
  25. function slideit(){   
  26.     var oImg = document.getElementById("javascript.img");   
  27.     if (document.all){oImg.filters.blendTrans.apply();}   
  28.     oImg.src=ImgSrc[step];   
  29.     document.getElementById("javascript.a").href=ImgHerf[step];   
  30.     oImg.title=ImgAlt[step];   
  31.     if (document.all){oImg.filters.blendTrans.play();}   
  32.     step = (step<(ImgSrc.length-1))?(step+1):0;   
  33.     (new Image()).src = ImgSrc[step];//加载下一个图片   
  34. }   
  35. setInterval("slideit()",3000);   
  36. //-->   
  37. </script>  

经测试,在IE7和firefox下都可以显示效果,不过两者的效果有些区别.

 

php截取文件扩展名极简单代码

2007年10月15日 渴慕晨光 没有评论

之前有发过一篇文章,那是写的三个小函数,今天见到极其简单的.

PHP代码
  1. // 第一种     
  2. $extendname = array_pop(explode ( ".",$filename));     
  3.   
  4. // 第二种     
  5. $extendname = end(explode("."$filename));     
  6.   
  7. // 第三种     
  8. $file_part  = pathinfo($filename);     
  9. $extendname = $file_part["extension"];    
分类: web编程 标签: , , ,

网页中图片平滑轮换滚动,非flash源代码

2007年10月15日 渴慕晨光 2 条评论

效果不错的图片轮换滚动,平滑滚动,可以自己设置图片大小,给图片加链接,说明.

效果见http://www.thefurniturespot.ca/.

XML/HTML代码
  1. <div id="top_pic" style="width:592px; height:348px; padding:0px; margin:0px; border:0px;" >  
  2. <script>  
  3. var NowFrame = 1;   
  4. var MaxFrame = 4;   
  5. var bStart = 0;   
  6. function fnToggle() {   
  7. var next = NowFrame + 1;   
  8. if(next == MaxFrame+1)   
  9. {   
  10.   
  11. NowFrame = MaxFrame;   
  12. next = 1;   
  13. }   
  14. if(bStart == 0)   
  15.   
  16. {   
  17. bStart = 1;   
  18.   
  19. setTimeout('fnToggle()', 1000);   
  20. return;   
  21. }   
  22. else   
  23. {   
  24. oTransContainer.filters[0].Apply();   
  25. document.images['oDIV'+next].style.display = "";   
  26. document.images['oDIV'+NowFrame].style.display = "none";   
  27. oTransContainer.filters[0].Play(duration=2);   
  28. if(NowFrame == MaxFrame)   
  29. NowFrame = 1;   
  30. else   
  31. NowFrame++;   
  32. } setTimeout('fnToggle()', 4000);   
  33. }   
  34. fnToggle();   
  35. </script>  
  36. <div id=oTransContainer style="FILTER: progid:DXImageTransform.Microsoft.Wipe(GradientSize=1.0, wipeStyle=0, motion='forward');HEIGHT: 348px; WIDTH: 592px ">  
  37. <a href="javascript:;"><IMG id=oDIV1 style="DISPLAY: none;" src="upfiles/<?=$row['img1']?>" height=348 width=592 border=0 alt="main photo"></A>  
  38. <a href="javascript:;"><img id=oDIV2 style="DISPLAY: none;" src="upfiles/<?=$row['img2']?>" height=348 width=592 border=0 alt="main photo"></a>  
  39. <a href="javascript:;"><img id=oDIV3 style="DISPLAY: none;" src="upfiles/<?=$row['img3']?>" height=348 width=592 border=0 alt="main photo"></a>  
  40. <a href="javascript:;"><img id=oDIV4 style="DISPLAY: none;" src="upfiles/<?=$row['img4']?>" height=348 width=592 border=0 alt="main photo"></a>  
  41.   
  42. </div>  
  43. </div>  

PHP生成图片缩略图的源代码

2007年10月12日 渴慕晨光 没有评论

刚用的时候因为php自带的函数大小写错误,所以不能使用,后来修改一下,可以使用.经测试在php5,apache下可以正常使用.

$srcFile,$toW,$toH,$toFile 四个参数就是,源文件,宽,高,输出文件.

 

PHP代码
  1. function ImageResize($srcFile,$toW,$toH,$toFile="")    
  2. {   
  3.     if($toFile==""){ $toFile = $srcFile; }   
  4.     $info = "";   
  5.     $data = getimagesize($srcFile,$info);   
  6.     switch ($data[2])    
  7.     {   
  8.         case 1:   
  9.         if(!function_exists("imagecreatefromgif")){   
  10.             echo "你的GD库不能使用GIF格式的图片,请使用Jpeg或PNG格式!<a href='java script:go(-1);'>返回</a>";   
  11.             exit();   
  12.         }   
  13.         $im = imagecreatefromgif($srcFile);   
  14.         break;   
  15.         case 2:   
  16.         if(!function_exists("imagecreatefromjpeg")){   
  17.             echo "你的GD库不能使用jpeg格式的图片,请使用其它格式的图片!<a href='java script:go(-1);'>返回</a>";   
  18.             exit();   
  19.         }   
  20.         $im = imagecreatefromjpeg($srcFile);    
  21.         break;   
  22.         case 3:   
  23.         $im = imagecreatefrompng($srcFile);    
  24.         break;   
  25.     }   
  26.     $srcW=imagesx($im);   
  27.     $srcH=imagesy($im);   
  28.     $toWH=$toW/$toH;   
  29.     $srcWH=$srcW/$srcH;   
  30.     if($toWH<=$srcWH){   
  31.         $ftoW=$toW;   
  32.         $ftoH=$ftoW*($srcH/$srcW);   
  33.     }   
  34.     else{   
  35.         $ftoH=$toH;   
  36.         $ftoW=$ftoH*($srcW/$srcH);   
  37.     }    
  38.     if($srcW>$toW||$srcH>$toH)   
  39.     {   
  40.         if(function_exists("imagecreatetruecolor")){   
  41.             $ni = imagecreatetruecolor($ftoW,$ftoH);   
  42.             if($ni) {   
  43.                 imagecopyresampled($ni,$im,0,0,0,0,$ftoW,$ftoH,$srcW,$srcH);   
  44.             }   
  45.             else{   
  46.                 $ni=imagecreate($ftoW,$ftoH);   
  47.                 imagecopyresized($ni,$im,0,0,0,0,$ftoW,$ftoH,$srcW,$srcH);   
  48.             }   
  49.         }else{   
  50.             $ni=imagecreate($ftoW,$ftoH);   
  51.             imagecopyresized($ni,$im,0,0,0,0,$ftoW,$ftoH,$srcW,$srcH);   
  52.         }   
  53.             if(function_exists('imagejpeg')) imagejpeg($ni,$toFile);   
  54.             else imagepng($ni,$toFile);   
  55.             imagedestroy($ni);   
  56.     }   
  57. imagedestroy($im);   
  58. }  
分类: web编程 标签: , ,

php上传图片,上传文件简单处理代码(非类)

2007年10月7日 渴慕晨光 1 条评论

 看到有人用的php上传处理代码,我主要用来处理上传图片了.使用的时候很简单,比如有一个name=“thumb”的文件域,上传的时候这样处理就可以了。

$image1 = get_fileform("thumb", $image1_name, $image1_type, $image1_size);
 
if($image1) $thumb=upfile1($code,$image1,$image1_name);

$thumb就是上传之后的相对url地址。比较简单。
upfile1()函数是上传文件的,里面可以设定文件命名的规则和要上传到的目录,可以很好的修改.

PHP代码
  1. //上传处理   
  2. function upload_file_name_ck($uploadfilename){   
  3.     if(eregi("\.php|\.php3|\.html|\.htm|\.phtml|\.com|\.bat|\.exe|\.inc|\.js|\.ph|\.asp|\.jsp|\.cgi|\.pl",$uploadfilename)){   
  4.         msg_back('上传文件格式不正确.');   
  5.     }   
  6.     else $check='2';   
  7.     return($check);   
  8. }   
  9. function samefile_chk($file_name$updir) {   
  10.     while($file_name and file_exists("$updir/$file_name")) {   
  11.         $temp = explode("."$file_name);   
  12.         $temp[0] = $temp[0] . "1";   
  13.         $file_name = implode("."$temp) ;   
  14.     }   
  15.     return $file_name;   
  16. }   
  17. function get_fileform($image$image_name$image_type$image_size$arr = "default")   
  18. {   
  19.     if($arr != "default"){   
  20.         if(isset($_FILES[$image]['name'][$arr])){   
  21.             $image_name = $_FILES[$image]['name'][$arr];   
  22.         }else{$image_name = NULL;}   
  23.   
  24.         if(isset($_FILES[$image]['size'][$arr])){   
  25.             $image_size = $_FILES[$image]['size'][$arr];   
  26.         }else{$image_size = 0;}   
  27.   
  28.         if(isset($_FILES[$image]['type'][$arr])){   
  29.             $image_type = $_FILES[$image]['type'][$arr];   
  30.         }else{$image_type = NULL;}   
  31.   
  32.         if(isset($_FILES[$image]['tmp_name'][$arr])){   
  33.             return $_FILES[$image]['tmp_name'][$arr];   
  34.         }   
  35.         return NULL;   
  36.     }   
  37.     else{   
  38.         if(isset($_FILES[$image]['name'])){   
  39.             $image_name = $_FILES[$image]['name'];   
  40.         }else{$image_name = NULL;}   
  41.   
  42.         if(isset($_FILES[$image]['size'])){   
  43.             $image_size = $_FILES[$image]['size'];   
  44.         }else{$image_size = 0;}   
  45.   
  46.         if(isset($_FILES[$image]['type'])){   
  47.             $image_type = $_FILES[$image]['type'];   
  48.         }else{$image_type = NULL;}   
  49.   
  50.         if(isset($_FILES[$image]['tmp_name'])){   
  51.             return $_FILES[$image]['tmp_name'];   
  52.         }   
  53.         return NULL;   
  54.     }   
  55. }   
  56.   
  57. function upfile1 ($code,$myfile,$myfile_name)    
  58. {   
  59.     $new_id = date("ymdhi",time());   
  60.     $check=upload_file_name_ck($myfile_name);   
  61.     if($check!='2')exit;   
  62.     $datadir='../upfiles/';   
  63.     $t=explode("."$myfile_name);   
  64.     $t[0]=$new_id."_".$t[0];   
  65.     $filename = implode("."$t) ;   
  66.     $filename=samefile_chk($filename,$datadir);   
  67.     $filename=$code.'/'.$filename;   
  68.        
  69.     $dest = $datadir.$filename;   
  70.     if(!move_uploaded_file($myfile,$dest)) {   
  71.         msg_back("Upload Error");   
  72.         exit;   
  73.     }   
  74. return ($filename);   
  75. }  

自用php好用,格式齐全的分页程序源代码

2007年9月14日 渴慕晨光 5 条评论

分页程序,用的时候很简单,用一下的代码,然后在要显示分页的地方用<?=$pagerstring?>就可以了.三种页码显示样式.

循环输出$result就可以了.使用时:
<?

  1. /* 分页*/  
  2. $page = isset($_REQUEST['page'])?$_REQUEST['page']:1;
  3. $numperpage=10;
  4. $start = ($page-1)*$numperpage
  5. $where = ...;
  6. $query = "SELECT id FROM bh_articles WHERE $where ";
  7. $query_result = mysql_query($query);
  8. $total_records = @mysql_num_rows($query_result);
  9. $pagerstring = pager($total_records$numperpage'?'$page);
  10. $limit=$start.",".$numperpage;
  11. $query = "SELECT id, title, summary, timestamp FROM bh_articles WHERE $where ORDER BY timestamp DESC limit $limit";
  12. $result = $db->query($query);

?>

PHP代码
  1. //php函数pager()   
  2.   
  3. function pager($numrecord$pagesize$pagename='?'$page){   
  4.     //querystring   
  5.     $querystring = $pagename;   
  6.     if (isset($_GET)) {   
  7.         foreach ($_GET as $key=>$val) {   
  8.             $val = urlencode($val);   
  9.             if ($key != 'page') {   
  10.                 $querystring .= $key."=$val&";   
  11.             }   
  12.         }   
  13.     }   
  14.   
  15.     $numpage = ceil($numrecord/$pagesize);   
  16.     $pagerstring = "总计 <b>$numrecord</b> 条 分 <b>$numpage</b> 页显示 当前第<b>$page</b>页";   
  17.        
  18.     if ($page>1)   
  19.         $pagerstring .= " <a href={$querystring}page=1 class=pager>首页</a> ";   
  20.     else  
  21.         $pagerstring .= " 首页 ";   
  22.        
  23.     if ($page>1)   
  24.         $pagerstring .= " <a href={$querystring}page=".($page-1)." class=pager>上一页</a> ";   
  25.     else  
  26.         $pagerstring .= " 上一页 ";   
  27.        
  28.     if ($page<$numpage)     
  29.         $pagerstring .= " <a href={$querystring}page=".($page+1)." class=pager>下一页</a> ";   
  30.     else  
  31.         $pagerstring .= " 下一页 ";   
  32.            
  33.     if ($page<$numpage)     
  34.         $pagerstring .= " <a href={$querystring}page=$numpage class=pager>末页</a> ";   
  35.     else  
  36.         $pagerstring .= " 末页 ";   
  37.            
  38.     $pagerstring .= "跳转至第<select name\"=page\" onchange=\"window.location.href='{$querystring}page='+this.value\">";   
  39.     for ($i=1; $i<=$numpage$i++){   
  40.         $pagerstring .= "<option value=$i ";   
  41.         if ($page == $i)   
  42.             $pagerstring .= "selected";   
  43.         $pagerstring .= ">$i</option>\n";   
  44.     }   
  45.     $pagerstring .= "</select>页";   
  46.        
  47.     return $pagerstring;   

输出结果为:
总计 7 条 分 1 页显示 当前第1页 | [首页] [上一页] [下一页] [末页] 跳转至第

PHP代码
  1. function pager2($numrecord$pagesize$pagename='?'$page){   
  2.     //querystring   
  3.     $querystring = $pagename;   
  4.     if (isset($_GET)) {   
  5.         foreach ($_GET as $key=>$val) {   
  6.             $val = urlencode($val);   
  7.             if ($key != 'page') {   
  8.                 $querystring .= $key."=$val&";   
  9.             }   
  10.         }   
  11.     }   
  12.   
  13.     $numpage = ceil($numrecord/$pagesize);   
  14.        
  15.     $pagerstring = '';   
  16.     if ($page>1)   
  17.         $pagerstring .= " <span class=\"pager2\" style=\"background-color:#FF6500\" onmouseover=\"this.style.background='#F7AE08'\" onmouseout=\"this.style.background='#FF6500'\"><a href=\"{$querystring}page=1\"><span class=\"f8black2\"><<</span>第一页</a></span> ";   
  18.        
  19.     if ($page>1)   
  20.         $pagerstring .= " <span class=\"pager2\" style=\"background-color:#FF6500\" onmouseover=\"this.style.background='#F7AE08'\" onmouseout=\"this.style.background='#FF6500'\"><a href=\"{$querystring}page=".($page-1)."\"><span class=\"f8black2\"><<</span>上一页</a></span> ";   
  21.     if ($page<4){   
  22.         $first = 1;   
  23.     }else{   
  24.         $first = $page-3;   
  25.     }   
  26.     if ($first+4>$numpage)   
  27.         $last = $numpage;   
  28.     else  
  29.         $last = $first+4;   
  30.            
  31.     for ($i=$first$i<=$last$i++){   
  32.         if ($i==$page){   
  33.             $color='#F7AE08';   
  34.             $style='color:#000000';   
  35.         }else{   
  36.             $color='#FF6500';   
  37.             $style='';   
  38.         }   
  39.         $pagerstring .= " <span class=\"pager2\" style=\"background-color:$color\" onmouseover=\"this.style.background='#F7AE08'\" onmouseout=\"this.style.background='$color'\"><a href=\"{$querystring}page=$i\" style=\"$style\">$i</a></span> ";   
  40.     }   
  41.     if ($page<$numpage)     
  42.         $pagerstring .= " <span class=\"pager2\" style=\"background-color:$color\" onmouseover=\"this.style.background='#F7AE08'\" onmouseout=\"this.style.background='#FF6500'\"><a href=\"{$querystring}page=".($page+1)."\">下一页<span class=\"f8black2\">>></span></a></span> ";   
  43.            
  44.     if ($page<$numpage)     
  45.         $pagerstring .= " <span class=\"pager2\" style=\"background-color:$color\" onmouseover=\"this.style.background='#F7AE08'\" onmouseout=\"this.style.background='#FF6500'\"><a href=\"{$querystring}page=$numpage\">末页<span class=\"f8black2\">>></span></a></span> ";   
  46.     return $pagerstring;   
  47. }  

输出结果为:  第一页 上一页 下一页 末页

PHP代码
  1. function pager3($numrecord$pagesize$pagename='?'$page){   
  2.     //querystring   
  3.     $querystring = $pagename;   
  4.     if (isset($_GET)) {   
  5.         foreach ($_GET as $key=>$val) {   
  6.             $val = urlencode($val);   
  7.             if ($key != 'page') {   
  8.                 $querystring .= $key."=$val&";   
  9.             }   
  10.         }   
  11.     }   
  12.   
  13.     $numpage = ceil($numrecord/$pagesize);   
  14.        
  15.     $pagerstring = '';   
  16.        
  17.     if ($page>1)   
  18.         $pagerstring .= " <span class=\"pager3\"><a href=\"{$querystring}page=".($page-1)."\">前一页</a></span> ";   
  19.        
  20.     $first = max((floor($page/5)-1)*5+1, 1);   
  21.     $last = min($first+5, $numpage);   
  22.            
  23.     for ($i=$first$i<=$last$i++){   
  24.         if ($i==$page){   
  25.             $pagerstring .= " <b>$i</b></a> ";   
  26.         }else{   
  27.             $pagerstring .= " <span class=\"page3\"><a href=\"{$querystring}page=$i\">$i</a></span> ";   
  28.         }   
  29.     }   
  30.        
  31.     if ($page<$numpage)     
  32.         $pagerstring .= " <span class=\"pager3\"><a href=\"{$querystring}page=".($page+1)."\">后一页</a></span> ";   
  33.            
  34.     return $pagerstring;   
  35. }  

输出结果为:  前一页 后一页.