fetching columns using pdo 28php data object 29

Solutions on MaxInterview for fetching columns using pdo 28php data object 29 by the best coders in the world

showing results for - "fetching columns using pdo 28php data object 29"
Amy
14 Oct 2017
1Code:
2$conn = new PDO("mysql:host=localhost;dbname=db_user", "root", "");
3$query = $conn->prepare("SELECT * FROM tbl_user WHERE id > ?");
4            $query->execute([10]);
5            $result = $query->fetchAll(PDO::FETCH_COLUMN, 1);
6            echo "<pre>";
7            print_r($result);
8            echo "</pre>";
9            
10Output:
11Array
12(
13    [0] => Fatema Akter
14    [1] => Roksana Akter
15    [2] => Syed Fahim
16    [3] => Tonmoy Ahmed 
17    [4] => Jannatul Ferdous
18    [5] => Mahabuba Rahman Porshi
19    [6] => Kaium Ahmed
20    [7] => Rabbi Islam
21    [8] => Md. Fahad Monshi
22    [9] => Arif Hossain
23)
24