<?php
include 'connection.php';
$userid = $_POST['userid'];
if (isset($userid)){
	$upfullname = $_POST['upfullname'];
	$upsql = $dbh->prepare("update users set fullname = '$upfullname' where id = '$userid'");
	$upsql->execute();
	echo "Record updated!<br>";
}



$sql = $dbh->prepare("select id,fullname from users");
$sql->execute();
while ($row = $sql->fetch()){
 $id = $row[0];
 $fullname = $row[1];
?>
<form action = "update.php" method="post">
<?php

 echo '<input type="text" name="upfullname" value="'.$fullname.'"><br>';
 //or it could equal $fullname = $row['fullname'];
 //or it could equal $id = $row['id'];
 ?>
 <input type="hidden" name = "userid" value = "<?php echo $id;?>">
 <input type="submit" name="submit" value = "Edit <?php echo $fullname;?>">
</form>
<?
}
?>