简体   繁体   English

在从php中的mysql表获取的数据数组中创建新列

[英]Create a new column in an array of data fetched from mysql table in php

$sqlfees = "SELECT feeid,occurence FROM feedetails WHERE applicablefor='$class'"; 
//fetching data
$fees_query = mysqli_query($db_conx, $sqlfees); 
//executing query
$count = mysqli_num_rows($fees_query);
if($count > 0) {
    while($fetch = mysqli_fetch_array($fees_query)) {
        $feesarr[] = $fetch; //creating array
}

I want to add a new column to $feesarr named 'dates' along with feeid and occurence with some values 我想在$ feesarr中添加一个名为'dates'的新列以及Feeid和出现的值

Try something like this 试试这个

     $sqlfees = "SELECT feeid,occurence FROM feedetails WHERE applicablefor='$class'"; 
     //fetching data
     $fees_query = mysqli_query($db_conx, $sqlfees); 
     //executing query
     $count = mysqli_num_rows($fees_query);
     if($count > 0) {
    while($fetch = mysqli_fetch_array($fees_query)) {
      $new_arr['date'] = $fetch['id'].'/'.other field what you want;
      $feesarr[] = array_merge($fetch, $new_arr); //creating array
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM