Skip to content

PHP code snippet – How to fetch all column values ?

<?php
$gsent = $gbd->prepare("SELECT name, colour FROM fruit");
$gsent->execute();

/* Obtener todos los valores de la primera columna */
$resultado = $gsent->fetchAll(PDO::FETCH_COLUMN, 0);
var_dump($resultado);
?>
See also  How to find last index of list in Python?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.