Search code examples
phpjsonsqliteselect-query

Removing title from select query in PHP


Is there any way to select a table in SQLite without printing the column headers?

The following is the code I am using:

SELECT realPow, timestamp 
FROM PowerData;

//To loop through the table and fetch the data for Real power
while($res = $results->fetchArray(SQLITE3_ASSOC)){
    $equal[] = $res;
}
echo json_encode($meArray,JSON_NUMERIC_CHECK);

Result:

[{"realPow":50,"timestamp":1391990400},{"realPow":200,"timestamp":1392422400},
{"realPow":100,"timestamp":1394409600},{"realPow":150,"timestamp":1395273600},
{"realPow":140,"timestamp":1397952000},{"realPow":130,"timestamp":1398384000},
{"realPow":120,"timestamp":1400544000},{"realPow":90,"timestamp":1402358400},
{"realPow":100,"timestamp":1402790400}]

I want to remove the "realPow:" & "timestamp:".


Solution

  • Here is your code modified:

    SELECT realPow, timestamp FROM PowerData;
    
        //To loop through the table and fetch the data for Real power
        while($res = $results->fetchArray(SQLITE3_ASSOC)){
            $equal[] = array($res['realPow'], $res['timestamp']);
        }
        echo json_encode($meArray,JSON_NUMERIC_CHECK);