在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
连接方法:$db=mysqli_connect("127.0.0.1","用户名","密码","数据库名")or die("Mysql连接失败" . mysqli_connect_error()); $sql="sql语句"; $res=$db->query($sql); $str=''; foreach($res as $k => $v){ $str .=implode(',',$v) . '-'; $str =substr($str ,0, strlen($str) -1); echo $str; ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 输出json格式 $arr=array(); foreach($res as $k => $v){ if($v['open']==0){ $list[$k]['id'] = $v['id']; 箭值对格式 } $list[$k]['id'] = $v['id']; } $json =json_encode($list); echo $json;
----------------------------------------------------------------------------------------------------------------------------------- ajax返回在页面上输出 function fangru(arr){ //arrj就是查出来的数据以‘-’分割 var brr=[]; var str =""; for(var i =0;i<arr.length;i++){ brr=arr[i].split(','); str +='<li onclick=\" xiangqing('+brr[0]+')\">\n'+ ' <div class=\"a-content\">\n' + ' <img class=\"left\" src=" '+brr[1]+' ">\n'+ ' <h3 class=\"right\">\n'+ brr[3] + ' </h3>\n'+ ' </div>\n'+ '<li>'; } //然后把数据放入到html里面 $('.a-content').html(str); } |
2022-08-17
2022-11-06
2022-07-29
2022-08-18
2022-07-30
请发表评论