php - JSON:使用 mysql 列过滤 mysql 数据 (PHP)
问题描述
{
"data": [
{
"title": "Section 1",
"section": [
{
"name": "Donut",
"image": "https://thecustomizewindows.com/wp-content/uploads/2011/11/Nicest-Android-Live-Wallpapers.png"
}
]
},
{
"title": "Section 2",
"section": [
{
"name": "Donut",
"image": "https://thecustomizewindows.com/wp-content/uploads/2011/11/Nicest-Android-Live-Wallpapers.png"
}
]
},
{
"title": "Section 3",
"section": [
{
"name": "Donut",
"image": "https://thecustomizewindows.com/wp-content/uploads/2011/11/Nicest-Android-Live-Wallpapers.png"
}
]
}
]
}
我有这样写的PHP:function getAllVideo(){
$stmt = $this->con->prepare("SELECT * FROM video");
$stmt->execute();
$stmt->bind_result($v_id,$video_image,$video_name,$category);
$video = array();
$action = array();
while($stmt->fetch()){
$temp = array();
$temp['v_id'] = $v_id;
$temp['video_image'] = $video_image;
$temp['video_name'] = $video_name;
$temp['category'] = $category;
array_push($video, $temp);
}
return $video;
}
你能帮我如何设计这段代码吗?我有类别列,想像这样在 Json 中排序。请协助。我正在使用 Slim-3 框架,需要 json 格式。
解决方案
推荐阅读
- sql - 基于连续数据的行编号?
- typescript - 使用 Observable 数组自动完成 Angular 材料芯片
- html - 为什么 div 元素表现得像一个容器?
- java - 如何准确地从通量中获得 n 个成功的操作结果?
- php - 仅在子类别中显示产品计数器 - WooCommerce
- tensorflow - 为什么即使停止我的 tensorflow 对象检测脚本后内存使用量也不会下降?
- excel - 如何让我的搜索程序区分相似的命名单元格内容?
- python - Python Regex 检查信用卡
- python-3.x - 无论如何要获取我放入 for 循环中的 Entry Widget 的所有值吗?
- reactjs - 使用 React 测试库 / Jest 模拟 axios 帖子