RsD0p9BK
11/20/2017 - 11:13 AM

Fetching multiple columns of a database

// Fetching multiple columns of a database

// grab all columns and put index numbers for each column
$allColumns = $user_database->fetchAll(PDO::FETCH_NUM);

// grab first column
$con = array_column($allColumns, 0);
// grab second column
$gan = array_column($allColumns, 1);

// this will output the variables so you can see what was grabbed   
echo '<pre>$con:  '; var_dump($con); 
echo '<pre>$gan:  '; var_dump($gan);


// https://stackoverflow.com/a/38151094/2618535