请PHP高手帮我个修改一下,被全功能。谢谢
程序分3个功能
1。页面打开随机选择30后显示。(没有问题)
2。查询功能(如s2)(比如这里输入一个很短的字。全显示非常多的数库。我想在这里只显示30条。)
3。显示单个页面(如s3) (想在这个下面在加一个根首页一样的随机选择30条。)
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --><?php set_time_limit(0); $prescription = trim($_GET['q']); $id = intval(base64_decode($_GET['id'])); $r_num = 0; //结果个数 $lan = 1; //首页分列 $pf = ""; $pf_l = ""; if($prescription!=""){ $dreamdb=file("date/njjzw.dat");//读取库 $count=count($dreamdb);//计算行数 for($i=0; $i<$count; $i++) { $keyword=explode(" ",$prescription);//拆分关键字 $dreamcount=count($keyword);//关键字个数 for ($ai=0; $ai<$dreamcount; $ai++) { @eval("\$found = eregi(\"$keyword[$ai]\",\"$dreamdb[$i]\");"); //按行查询 if(($found)){ $detail=explode("\t",$dreamdb[$i]);//按tab if(fmod($r_num,$lan)==0) $pf_l .= "<tr>"; $pf_l .= '<td width="'.(100/$lan).'%"><img src="/img/dot.gif" />'; $pf_l .= '<a href="'.base64_encode(($i+1)).'.html">'.$detail[0].'</a></br></td>'; if(fmod($r_num,$lan)+1==$lan) $pf_l .= "</tr>"; $r_num++; break; } } } $pf_l = '<div class="zt"><b><a href="./">脑筋急转弯大全</a>:找到 <a href="./?q='.urlencode($prescription).'"><font color="#c60a00">'.$prescription.'</font></a> 的相关'.$r_num.'个</b></div><div class="wenzi"><table cellpadding="5" cellspacing="10" width="100%">'.$pf_l.'</table> </p></div> <!--内容结束--> '; }elseif($id>0){ $dreamdb=file("date/njjzw.dat");//读取库 $count=count($dreamdb);//计算行数 $detail=explode("\t",$dreamdb[$id-1]); $pf = '<div class="zt"><b><a href="./">脑筋急转弯大全</a> /脑筋急转弯问题</b><td align="right">'; $pf .= '</td></tr><tr></div><div class="wenzi"><table cellpadding="5" cellspacing="10" width="100%"><tr><td colspan="3"><h3> <P class="f14 l200">脑筋急转弯:'.$detail[0].'<SPAN class=hidden>http://www.vipcha.net/naojinjizhuanwan/Mjcx.html</SPAN></P> <P id=midir class="f14 hidden">答案:'.$detail[1].'</P> <P id=midi class=f14><A class=f14 onclick="document.getElementById("midi").innerHTML = document.getElementById("midir").innerHTML;" href="javascript:void(0)">查看答案</A></P> </h3></td></tr><tr> </tr></tr></table></div>'; }else{ $dreamdb=file("date/njjzw.dat");//读取库 $count=count($dreamdb);//计算行数 $pfl = rand(0,intval($count/30)); for($i=$pfl*30; $i<$pfl*30+30; $i++) { if($i>=$count-1) break; $detail=explode("\t",$dreamdb[$i]); if(fmod($r_num,$lan)==0) $pf_l .= "<tr>"; $pf_l .= '<td width="'.(100/$lan).'%"><img src="/img/dot.gif" />'; $pf_l .= '<a href="'.base64_encode(($i+1)).'.html">'.$detail[0].'</a></br></td>'; if(fmod($r_num,$lan)+1==$lan) $pf_l .= "</tr>"; $r_num++; } $pf_l = '<div class="zt"><b>推荐脑筋急转弯大全'.$r_num.'个</b></div><div class="wenzi"><table cellpadding="5" cellpacing="10" width="100%">'.$pf_l.'</table> </p></div><!-- 内容まとめ-->; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>脑筋急转弯</title> </head> <body><div id="main"> <form action="./" method="get" name="f1"> <input name="q" type="text" size="20" maxlength="20" value=""/> <input type="submit" id="sub" value="查询" /></form> </div> <div class="huisefengexian"></div> if($処方箋!=""){ エコー $pf_l; }elseif($id>0 && $id </div></body> </html> <div class="clear"></div>