php搜索怎么做本人刚刚学习

[复制链接]
查看11 | 回复8 | 2011-9-15 07:40:44 | 显示全部楼层 |阅读模式
有以下表news字段标题:title内容content和id现在我有写一个表单搜索标题的,在线等希望高手快些最好写规范些代码最好给加上分页
回复

使用道具 举报

千问 | 2011-9-15 07:40:44 | 显示全部楼层

回复

使用道具 举报

千问 | 2011-9-15 07:40:44 | 显示全部楼层
soeasy.就是根据标题查找内容是把。我不知道你会到什么程度啊,会连接数据库吧??phpinclude\"page.php\";//分页类//这个是list2,php//连接数据库省略了$title=$_GEt[\'title\'];$msgcount=mysql_query(\"selectcount(*)fromnewswheretitle=‘$title’\");$page=$_GEt[\'page\'];下面我写分页的。$pagesize=\"4\";$startnum=($page-1)*$pagesize;//写到这里也不知道你会不会smarty。。。。$pagestring=newPage($page,$pagesize,$msgcount,\"url这个是你的php文件地址\");$result=mysql_query(\"select*fromnewswheretitle=‘$title’limit\'$startnum,$pagesize\'\");$this-smarty-assign(\"pagestaring\",$pagestaring);$this-smarty-assign(\"result\",$result);$this-smarty-display(\"你的模版//xxxx.html\");ok了。分页类我给你:?phpclassPage{staticfunctionpager($page,$msg_count,$pagesize,$url=\'?\'){//计算总页数$page_count=ceil($msg_count/$pagesize);//下一页的页码$nextpage=$page1;//上一页的页码$lastpage=$page-1;if($page$page_count){$page=$page_count;}//定义分页字符串$pagestring=\'\';$pagestring.=\"总数:$msg_count页数:$page/$page_countahref=\'$url\".\"首页/a\";if($page1){$pagestring.=\"ahref=\'$url\".\"上页/a\";}else{$pagestring.=\"ahref=\'#\'上页/a\";}if($page5){$startpage=1;}if($page=5($page_count-5)){$startpage=$page-4;}if($page=($page_count-5)5){$startpage=$page_count-9;}if($page_count=10){$startpage=1;}if($page5){if($page_count=10)$endpage=10;else$endpage=$page_count;}if($page=($page_count-5))$endpage=$page_count;if($page=5($page_count-5))$endpage=$page5;for($i=$startpage;$i=$endpage;$i){if($page==$i)$pagestring.=\"ahref=\'#\'class=\'thispage\'$i/a\";else$pagestring.=\"ahref=\'$url\".\"$i/a\";}if($page$page_count){$pagestring.=\"ahref=\'$url\".\"下页/a\";}else{$pagestring.=\"ahref=\'#\'下页/a\";}$pagestring.=\"ahref=\'$url\".\"末页/a\";return$pagestring;}}?完成了。。。。。。很辛苦呀。好好学习吧,php的学习要多看源码的!?追问好的先谢谢等下我测试一下看看行吗$this-smarty-display(\"你的模版//xxxx.html\");这个是什么意思,模板????谢谢还是不行我已经又补充好问题啦,链接数据库已经在top里面希望能更详细些
回复

使用道具 举报

千问 | 2011-9-15 07:40:44 | 显示全部楼层
你不会smarty埃。。那你在html里面引入我写的list2.php然后把$this-smarty-assign(\"pagestaring\",$pagestaring);$this-smarty-assign(\"result\",$result);$this-smarty-display(\"你的模版//xxxx.html\");这个替换掉,会写foreach吧?将$result循环输出,然后找个地方echo$pagestring上面有个地方写“php文件地址的”,你写./list.php
回复

使用道具 举报

千问 | 2011-9-15 07:40:44 | 显示全部楼层
哦????你这个是从数据库中找的标题还是从静态页面上全页面的搜索呢谢谢
回复

使用道具 举报

千问 | 2011-9-15 07:40:44 | 显示全部楼层
这要求也太高了,你可以用mysql来搜索内容啊,想模糊查询可以用select*fromnewwherecontentlike\'%搜索字段%\'参考资料:http://www.ityizhan.com/tag/mysql/
回复

使用道具 举报

千问 | 2011-9-15 07:40:44 | 显示全部楼层
楼上的对
回复

使用道具 举报

千问 | 2011-9-15 07:40:44 | 显示全部楼层
报个培训班学习哈嘛我晓得银河教育培训先锋不错··
回复

使用道具 举报

千问 | 2011-9-15 07:40:44 | 显示全部楼层
从表单提交关键字通过phpmysql处理就可以了,php语句获取你的关键字,mysql里找出去你搜索的内容,返回给php处理后再打印出来。基本上就是这么一个流程。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行