|
我刚学php...前两天才开始的....想通过写个留言本来学习
不知道为什么会出现这个错话..我不知道怎么描述好..
我明明是让它从o开始的..怎么运行后(如图)变成负数了...
我把代码粘上来 大家谁有空的话..帮帮我吧..谢谢了
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
- <title>Shrimpy`s GuestBook!!!</title>
- <link href="/SGB.css" rel="stylesheet" type="text/css">
- <style type="text/css">
- <!--
- .style1 {
- font-size: 12px;
- color: #666699;
- }
- .style2 {
- font-size: 12px;
- font-family: "宋体";
- }
- -->
- </style>
- </head>
- <body>
- <form action="index.php?type=add" method="post" name="postthreads" class="unnamed1" id="postthreads">
- <div align="center">
- 你的大名(*):
- <input name="guestname" type="text" id="guestname" value="" size="20" maxlength="50">
- <br>
- 你的标题(*):
- <input name="threadtitle" type="text" id="threadtitle" size="20" maxlength="200">
- <br>
- 来自:
- <input name="guestfrom" type="text" id="guestfrom" size="20" maxlength="200">
- <br>
- 主页:
- <input name="guestpage" type="text" id="guestpage" value="http://" size="20" maxlength="200">
- <br>
- email:
- <input name="guestemail" type="text" id="guestemail" value="@" size="20" maxlength="200">
- <br>
- <br>
- <textarea name="threadcontent" cols="40" rows="10" id="threadcontent">内容!!!
- 我什么都不写你吹!!!</textarea>
- <br>
- <input type="submit" name="Submit" value="提交">
- </div>
- </form>
- <div align="center"><br>
- <?php
- if($_GET[type]=="add"){
- $guestname =$_POST['guestname'];
- $threadtitle =$_POST['threadtitle'];
- $guestfrom =$_POST['guestfrom'];
- $guestpage =$_POST['guestpage'];
- $guestemail =$_POST['guestemail'];
- $threadcontent=$_POST['threadcontent'];
- $threadcontent=htmlspecialchars($threadcontent);
- $threadcontent=ereg_replace("\r\n","<br>",$threadcontent);
- $threadcontent=ereg_replace("\r","<br>",$threadcontent);
- $td =date("Y年n月d日 g:i:s a l"); //2005年1月19日 5:39:20 pm Thursday ************
- $linestore =$td."||".$guestname."||".$threadtitle."||".$guestfrom."||".$guestpage."||".$guestemail."||".$threadcontent."\n"; //collect all the message in order to store into data.txt
- $temp =fopen("data.txt","r+");
- $tempdata =fread($temp,filesize("data.txt"));
- fclose($temp);
- $f =fopen("data.txt","r+"); //get handle
- fputs($f,$linestore);
- fputs($f,$tempdata);
- fclose($f); // bring data into data.txt
- } ?>
- <br>
- </div>
- <?
- $file =file("data.txt");
- $datanum =sizeof($file);
- $pagesize =3; // each page three threads
- $pagenum =ceil($datanum/$pagesize); //total pages
- $currentpage =1; //initial
- $currentpage =$page; // control prevpage and nextpage
- if($_GET[ps]=="stridenow"){ // control striding page
- $currentpage=$_POST['stridepage'];}
- $prevpage =$currentpage-1;
- $nextpage =$currentpage+1;
- $toppost =($currentpage-1)*$pagesize;
- $bottompost =($currentpage*$pagesize);
- ?>
-
-
- <div align="center"><br>
- <form action="index.php?ps=stridenow" method="post" name="stride" id="stride">
- 你现在在<? echo $currentpage ?>页 你想跳到
- <input name="stridepage" type="text" id="stridepage" value="" size="3">
- 页
- <input type="submit" name="Submit2" value="ok">
- 一共有<? echo "$pagenum";?>页 </form>
- <br>
- </div>
-
-
- <?
- for($i=$toppost;$i<$bottompost;$i=$i+1)
- {
- echo $i;
- $expdata =explode("||",$file[$i]);
-
- ?>
- <table width="400" border="0" align="center" bordercolor="#FFCC66">
- <tr bgcolor="#FFCC66" class="unnamed1">
- <td colspan="2" class="unnamed1"><div align="right" class="style1"><? echo $expdata[0]; ?></div></td>
- </tr>
- <tr bgcolor="#CCCCCC" class="unnamed1">
- <td class="unnamed1"><div align="left"></div>
- 大名:<?php echo $expdata[1]; ?></td>
- <td class="unnamed1">来自:<? echo $expdata[3] ;?></td>
- </tr>
- <tr bgcolor="#CCCCCC" class="unnamed1">
- <td width="200" class="unnamed1"> <div align="left">邮箱:<a href="mailto: <? echo $expdata[5] ;?>"><? echo $expdata[5]; ?></a></div></td>
- <td class="unnamed1"><div align="left"><span class="unnamed1">页子:</span><a href="<? echo $expdata[4] ; ?>" target="_blank"><? echo $expdata[4]?></a></div></td>
- </tr>
- <tr bgcolor="#CCCCCC" class="unnamed1">
- <td colspan="2" class="unnamed1">标题:<?php echo $expdata[2]; ?></td>
- </tr>
- <tr bgcolor="#FFCC66" class="unnamed1">
- <td colspan="2" align="left" class="unnamed1"><?php echo $expdata[6]; ?></td>
- </tr>
- </table>
- <p><br>
- </p>
- </div>
- <? } //for ?>
- <div align="center"><? if($currentpage!=1){ ?>
- <p><a href=index.php?page=<? echo $prevpage ?>>上一页</a>
- <? } ?>
- <? if($currentpage!=$pagenum){ ?>
- <a href=index.php?page=<? echo $nextpage ?>>下一页</a><? } ?></p>
- </div>
-
- </body>
- </html>
复制代码 :help :help |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|