Fetching Columns Using PDO (PHP DATA OBJECT)
Code:
$conn = new PDO("mysql:host=localhost;dbname=db_user", "root", "");
$query = $conn->prepare("SELECT * FROM tbl_user WHERE id > ?");
$query->execute([10]);
$result = $query->fetchAll(PDO::FETCH_COLUMN, 1);
echo "<pre>";
print_r($result);
echo "</pre>";
Output:
Array
(
[0] => Fatema Akter
[1] => Roksana Akter
[2] => Syed Fahim
[3] => Tonmoy Ahmed
[4] => Jannatul Ferdous
[5] => Mahabuba Rahman Porshi
[6] => Kaium Ahmed
[7] => Rabbi Islam
[8] => Md. Fahad Monshi
[9] => Arif Hossain
)