I'm trying to get specific columns from a database table rather than selecting the whole table and put them to json format. There's no need for irrelevant columns. This is what i have so far.
$sql = "SELECT (col1,col2,col3) FROM table1";
$result = mysqli_query($connection, $sql) or die("Error in Selecting " . mysqli_error($connection));
$emparray = array();
while($row =mysqli_fetch_assoc($result))
{
$emparray[] = $row;
}
echo json_encode($emparray);
mysqli_close($connection);
This code returns with an error: Operand should contain 1 column(s)
Any ideas what I'm doing wrong?
Thanks