While this is not really an error, extra data that is not used should not be included in any output as it will only add to the extra bytes.
When you look at your JSON output, you realized the column names and values also have extra index column numbers and the associated values included.
To remove this, simply add an option in the PDO when you instantiate a database connection in PHP like this:
$db = new PDO("mysql:host=localhost; dbname=mydbname", "myusername", "mypassword");
That should fix the problem. When you use json_encode(), there will be no more duplicate values with the corresponding column index number as key.