php : 看书网页 : 上一页,下一页

get.php
<?php
 $dir= $_GET["dir"];
 $pre= $_GET["pre"];
 $end= (integer)$_GET["end"];
 $i= (integer)$_GET["i"];
 $i1 = $i -1;
 $i2 = $i +1;
 $s = sprintf("%03d", $i);
 $path=$dir."/".$pre.$s.".jpg";
?>
<html>
  <head>
   <base target="top"/>
    <meta http-equiv="Content-Type" content="text/html; charset=GBK">
    <title>IT Books </title>
    <style type="text/css">
      body {background:#FFFFFC;}
    </style>
  </head>
<body>
<?php
  if($i>1){
    echo '<a href="get.php?dir='.$dir.'&pre='.$pre.'&end='.$end.'&i='.$i1.'" >上一页</a> ';
  } else {
    echo '这是首页';
  }
  echo "&nbsp;&nbsp;&nbsp;&nbsp;\n";
  echo '<a href="'.$dir.'.htm" >中文目录</a>'."&nbsp;&nbsp;&nbsp;&nbsp;\n";
  if($i< $end){
    echo '<a href="get.php?dir='.$dir.'&pre='.$pre.'&end='.$end.'&i='.$i2.'" >下一页</a>'."\n";
  } else {
    echo '这是尾页';
  }
?>

  <p>
  <img src="<?echo $path;?>" alt="<?echo $path;?>"/>
  </p>
  
<?php
  if($i>1){
    echo '<a href="get.php?dir='.$dir.'&pre='.$pre.'&end='.$end.'&i='.$i1.'" >上一页</a> ';
  } else {
    echo '这是首页';
  }
  echo "&nbsp;&nbsp;&nbsp;&nbsp;\n";
  echo '<a href="'.$dir.'.htm" >中文目录</a>'."&nbsp;&nbsp;&nbsp;&nbsp;\n";
  if($i< $end){
    echo '<a href="get.php?dir='.$dir.'&pre='.$pre.'&end='.$end.'&i='.$i2.'" >下一页</a>'."\n";
  } else {
    echo '这是尾页';
  }
?>
</body>
</html>

猜你喜欢

转载自belldeep.iteye.com/blog/2369278