当前位置:网站首页>微信小程序之获取php后台数据库转化的json
微信小程序之获取php后台数据库转化的json
2022-06-23 13:12:00 【qq_45911550】
php代码:
<?php
// $username = array();
// $password = array();
$userandpass = array();
include "con_mysql.php";
$conn = con_mysql("localhost", "root", "", "supermarket");
$sql = "SELECT username, password FROM sup_user;";
$result = $conn->query($sql);
if ($result->num_rows > 0)
{
while($row = $result->fetch_assoc()) // 将表中的数据都取出来
{
$u_p = array();
// echo "username: ".$row['username']." password: ".$row["password"];
$u_p['username'] = $row['username'];
$u_p['password'] = $row['password'];
$userandpass[] = $u_p;
}
}
// $userandpass['username'] = $username;
// $userandpass['password'] = $password;
echo json_encode($userandpass);
?>
js代码:
// index.js
// 获取应用实例
const app = getApp()
Page({
data: {
t:"hwllo"
},
onLoad: function(){
var that = this;
wx.request(
{
url:"http://127.0.0.1/SM/select_alluser.php",
headers:{
'content-type':'application/json'
},
method:'GET',
success:res=>{
that.setData({
t:res.data
})
}
}
);
}
})
wxml代码:
<view wx:for="{
{t}}" wx:key="key">{
{
item.username}}</view>
<view wx:for="{
{t}}" wx:key="key">{
{
item.password}}</view>
后台返回的数据:

边栏推荐
- sed -i命令怎么使用
- IEEE Transaction期刊修改过程记录
- React query tutorial ④ - cache status and debugging tools
- OpenVINOTM 2022.1中AUTO插件和自动批处理的最佳实践
- Face registration, unlock, respond, catch all
- Detailed explanation of kubernetes log monitoring system architecture
- Online text entity extraction capability helps applications analyze massive text data
- AGCO AI frontier promotion (6.23)
- Basic data types of C language and their printouts
- 互联网技术发展内卷后的出路——iVX的诞生
猜你喜欢

Architecture design methods in technical practice

PHP handwriting a perfect daemon

CRMEB 二开短信功能教程

串口、COM、UART、TTL、RS232(485)区别详解

通过 OpenVINO Model Server和 TensorFlow Serving简化部署
[email protected] Hdmi2.0 optical transceiver HDMI HD video optical transceiver"/>4k-hdmi optical transceiver 1 channel [email protected] Hdmi2.0 optical transceiver HDMI HD video optical transceiver

腾讯云TDSQL-C重磅升级,性能全面领跑云原生数据库市场

Use openvinotm preprocessing API to further improve the reasoning performance of yolov5

2-optical-2-electric cascaded optical fiber transceiver Gigabit 2-optical-2-electric optical fiber transceiver Mini embedded industrial mine intrinsic safety optical fiber transceiver

Multi-Camera Detection of Social Distancing Reference Implementation
随机推荐
16 channel HD-SDI optical transceiver multi channel HD-SDI HD video optical transceiver 16 channel 3g-sdi HD audio video optical transceiver
在线文本过滤小于指定长度工具
kubernetes日志监控系统架构详解
1 channel 100m optical fiber transceiver 1 100m optical 1 100m electric desktop Ethernet optical fiber transceiver built-in power supply
Learning experiences on how to design reusable software from three aspects: class, API and framework
Esp32-c3 introductory tutorial problem ⑦ - fatal error: ESP_ Bt.h: no such file or directory ESP not found_ bt.h
Windows install MySQL
Scope of groovy
IEEE Transaction期刊修改过程记录
构建英特尔 DevCloud
Quartus II 13.1 安装步骤详解
Understand ADT and OOP
腾讯的技术牛人们,是如何完成全面上云这件事儿的?
Gary Marcus wrote: three perspectives from linguists that AI researchers need to know
How deci and Intel can achieve up to 16.8x throughput improvement and +1.74% accuracy improvement on mlperf
AI 参考套件
Service stability governance
如何正确计算导入Excel的行数(POI/NPOI)
白皮书丨英特尔携手知名RISC-V工具提供商Ashling,着力扩展多平台RISC-V支持
What a talented company that can turn SAP system into a chicken rib!