P
P
pamparumba2017-03-19 10:57:13
PHP
pamparumba, 2017-03-19 10:57:13

How to put all table values ​​in one array?

php. I have a table with many fields. The fields consist of id and name. It is necessary to bring the name value of all fields into one large array. How to do it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
AdrianBlair, 2017-03-19
@AdrianBlair

$host = ""; //Хост бд
$name = ""; // Имя бд
$user = ""; // Имя пользователя
$password = ""; // Пароль пользователя
$query = ""; // Запрос

try {
  $database = new PDO("mysql:host=$host;dbname=$name;charset=utf8", $user, $password);
  $database->EXEC("SET NAMES utf8");
} catch(PDOException $e) {
  die("Подключение не удалось: ". $error -> getMessage());
  exit;
}

$query = $database->prepare($query);
$query->execute();
$result = $sequery->fetchAll();

echo var_dump($result);

P
pamparumba, 2017-03-19
@pamparumba

This is the name of one line. And you need all in one array :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question