I'm trying to display individual values from a PDO statement to radio buttons. Here's what I have so far.
<?php
session_start();
$host = "localhost";
$username = "root";
$password = "";
$database = "training";
$result = "";
$connect = new PDO("mysql:host=$host; dbname=$database", $username, $password);
$query = "SELECT username FROM accounts";
$statement = $connect->prepare($query);
$statement->execute();
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
echo "<input type='radio' name ='president'>". $result . "</input>"
?>
but it results in this
"Notice: Array to string conversion in
C:\xampp\htdocs\testing\vote.php
"
I've tried using print_r($result);
to check the values
[0] = admin
[1] = operation1
I want those values to be displayed on radio buttons text.