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

时间:2015-04-03 10:25:42

标签: php mysql

$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
}

我想在$ feearr中添加一个名为' dates'以及带有一些价值的费用和出现

1 个答案:

答案 0 :(得分:1)

尝试这样的事情

     $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
    }