在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
<?php //从笑话表中得到数据 header("Content-type:text/html;charset=utf-8"); $conn=mysql_connect("localhost","zjwdb_91189","1314loveMM") or die("数据库服务器连接错误".mysql_error()); mysql_select_db("zjwdb_91189",$conn) or die("数据库访问错误".mysql_error()); mysql_query("SET NAMES utf8");//注意编码格式phpmyadmin中设置得为gbk,php中同样set name gbk $sql=mysql_query("select userID,content,date from pinglun order by date desc",$conn); $str="["; while( $row=mysql_fetch_row($sql)){ $Array = array("userID"=>$row[0], "content"=>$row[1],"date"=>$row[2]); $Array['content'] = urlencode ( $Array['content'] ); $str=$str.urldecode(json_encode( $Array)); $str=$str.","; } $str= utf8_substr($str,0,-1); $str= $str."]"; echo $str; mysql_free_result($sql); mysql_close($conn); function utf8_substr($str,$start=0) { if(empty($str)){ return false; } if (function_exists('mb_substr')){ if(func_num_args() >= 3) { $end = func_get_arg(2); return mb_substr($str,$start,$end,'utf-8'); } else { mb_internal_encoding("UTF-8"); return mb_substr($str,$start); }
} else { $null = ""; preg_match_all("/./u", $str, $ar); if(func_num_args() >= 3) { $end = func_get_arg(2); return join($null, array_slice($ar[0],$start,$end)); } else { return join($null, array_slice($ar[0],$start)); } } } ?> |
2022-08-17
2022-11-06
2022-08-17
2022-07-29
2022-07-29
请发表评论