php select data from mysql database without column name code example

Example 1: php select data from mysql database without column name

function sql($sql) {
  global $db_cnx;
    $T_Return=array();
    $result=mysqli_query($db_cnx,$sql);
   
    $i=0;
    while ($i < mysqli_num_fields($result)) {           
        $fields[]=mysqli_fetch_field($result);
        $i++;
    }
   
    while ($row=mysqli_fetch_row($result)) {               
        $new_row=array();
        for($i=0;$i<count($row); $i++) {
            $new_row[ $fields[$i]->table][$fields[$i]->name]=$row[$i];
        }
        $T_Return[]=$new_row;
    }

   
    return $T_Return;
}

Example 2: php select data from mysql database without column name

SHOW COLUMNS FROM table_name;

Tags:

Misc Example