菜鸟 问下PHP取出MYSQL数据,然后倒置顺序
mysql数据
php代码:
$res_ip = mysql_query("select * from ip order by id DESC limit 0,5");<br />while($row_ip = mysql_fetch_array($res_ip)){<br /> $ip_ip[] = intval($row_ip['ip']);<br /> $time_ip[] = date($row_ip['time']);<br />}<br />$data_ip = array(array("name"=>"IP流量","data"=>$ip_ip));<br />$data_ip = json_encode($data_ip);<br />$times_ip = json_encode($time_ip);<br />$times_ip = str_replace('2015-', '', $times_ip);["01-25","01-25","01-24","01-23","01-22"]
[{"name":"IP\u6d41\u91cf","data":[12632220,12735020,127350,2213488,2348888]}]["01-22","01-23","01-24","01-25","01-26"]
[{"name":"IP\u6d41\u91cf","data":[2348888,2213488,127350,12735020,12632220]}]$data_ip = array(array("name"=>"IP流量","data"=> array_reverse($ip_ip)));<br />$data_ip = json_encode($data_ip);<br />$times_ip = json_encode(array_reverse($time_ip));<br />$times_ip = str_replace('2015-', '', $times_ip);<br />
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号