Home  >  Article  >  Backend Development  >  根据访客来源显示不同的新闻

根据访客来源显示不同的新闻

WBOY
WBOYOriginal
2016-06-23 13:37:38975browse

用的是淘宝IP库
$ipinfo=json_decode(file_get_contents("http://ip.taobao.com/service/getIpInfo.php?ip=".$onlineip),true);
现在可以成功知道访客来源了。
我想的问的是,类似于腾讯首页那样,根据访客来源显示所在省的新闻。
接下来该怎么写。求完成的。

比如:用淘宝IP库:
echo '省份:'.$ipinfo['data']['region'];
数据库A,数据表B,数据表B有字段tiele,leixing,pro字段
就是比如放访客来自北京市时,那么调用pro=北京市的新闻。访客来自天津市时,那么调用pro=北京市的新闻。
如果是国外时,则按时间调用这个数据表的所有字段。
完整的该怎么写。
我0基础。
求助高手一下。


回复讨论(解决方案)

function viewnews( $pro){

select 字段1,字段2,字段3  from B where pro='$pro';
query

return  arry;

}

可能我想的简单点儿,  后来者补充

大点的网站可以用到缓存机制

function viewnews( $pro){

select 字段1,字段2,字段3  from B where pro='$pro';
query

return  arry;

}

可能我想的简单点儿,  后来者补充



我的意思是数据表调用新闻是根据淘宝对访客来源判断的结果。
貌似你这里没结合。

获取到的是国内的地址,就where pro = '$city'
是国外的话,把where去掉就行

select * from A where B like '%北京%'

SQL

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn