I've successfully populated a HTML form dropdown menu using this method, so I know it works, the difference this time is I'm trying to populate text boxes with content (account details), but it's just not working.
PHP:
try {
$sql = "SELECT Firstname, Surname, Email FROM `users`;";
$result = $pdo->query($sql);
}
catch (PDOException $e){
echo "There was an error whilst fetching the users information:" .$e->getMessage();
exit();
}
while($row=$result->fetch()){
$displayinfo[] = array('UserFirstName' => $row['Firstname'],
'UserSurname' => $row['Surname'],
'UserEmail' => $row['Email']);
}
HTML SIDE:
<?php foreach($displayinfo as $info): ?>
<?php echo "<input type="text" name="firstname" value=". $info['UserFirstName'] ."><br>"
?>
<?php endforeach; ?>
This seems to show a
Syntax error, unexpected T_String, expecting ',' or ';'
Any help would be appreciated
"<input type="text" name="firstname" value=". $info['UserFirstName'] ."><br>". You can change the quotes of attributes to single quotes'.inputelement perhaps