php - 在颤振中将表名传递给 getData.php
问题描述
我正在使用 MySQL 制作颤振应用程序。在主页中,我有一个列表视图,如下所示。数据库对列表视图中的每个项目都有唯一的表。
我想要的是,当我根据 getData.php 中提到的查询调用 http.get 从特定表中获取所有数据时,还必须有一个过程将该表名发送到该 php 文件,以便查询应该完成。
这是getData.php:
<?php
include 'conn.php';
$Table = $_POST['Tablename'];
$query = "select * from ".$Table;
$data = mysqli_query($conn, $query);
$result = array();
while ($row = mysqli_fetch_array($data)) {
$result[] = $row;
}
echo json_encode($result);
?>
这是我为获取数据而编写的代码。我可以写什么来将表名发送到 getData.php:
Future<List> getQue() async {
var response = await http.get(url);
return json.decode(response.body);
}
解决方案
使用post
而不是get
您的 http 调用;
Future getQue() async {
var response = await http.post(url, body:{'Tablename': your-table-name});
return json.decode(response.body);
}
推荐阅读
- orbbec - 将像素值转换为距离
- openpyxl - 如何在openpyxl中的数据验证中使用range_name作为列表?
- java - 连接到 JDBC MySQL 时出现异常
- python - Python 库 VapourSynth 的属性错误
- sql-server - 如何评估使用 MS SQL Server 与 Amazon Redshift 的成本?
- python - 使用逻辑运算符(时间值)将新项目附加到 Python 列表
- php - 从 API 接收数据并通过 AJAX 将其发送到另一个页面
- css - SCSS 正在编译为 CSS,但更改未显示在浏览器中
- d3.js - D3沿路径为任意svg设置动画
- elasticsearch - 带有嵌套字段的 Elasticsearch 插入适用于 Kibana,但不适用于 cURL