请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" alt=" 请PHP高手帮小弟我个修改一下,被全功能。多谢 " >'; $pf_l .= '<a href="'.base64_encode((%24i+1)).'.html">'.$detail[0].'</a> </td>'; if(fmod($r_num,$lan)+1==$lan) $pf_l .= ""; $r_num++; break; } } } $pf_l = '<div class="zt"><b><a href="./">脑筋急转弯大全</a>:找到 <a href="./?q='.urlencode(%24prescription).'"><font color="#c60a00">'.$prescription.'</font></a> 的相关'.$r_num.'个</b></div><div class="wenzi"> <table cellpadding="5" cellspacing="10" width="100%">'.$pf_l.'</table> </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> <div class="wenzi"><table cellpadding="5" cellspacing="10" width="100%"> <tr><td colspan="3"> <h3> </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 document.getelementbyid href="javascript:void(0)">查看答案</a></p> </td></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=$count-1) break; $detail=explode("\t",$dreamdb[$i]); if(fmod($r_num,$lan)==0) $pf_l .= "</tr> <tr>"; $pf_l .= '<td width="'.(100/$lan).'%"> <img src="/img/dot.gif" alt=" 请PHP高手帮小弟我个修改一下,被全功能。多谢 " >'; $pf_l .= '<a href="'.base64_encode((%24i+1)).'.html">'.$detail[0].'</a> </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" cellspacing="10" width="100%">'.$pf_l.'</table> </div> <!--内容结束-->'; } ?> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title></title> </div>