<?php
include 'connection.php';
$userid = $_GET['upid'];
$updateid = $_POST['userid'];
if (isset($updateid)){
	$upfullname = $_POST['upfullname'];
	$upsql = $dbh->prepare("update users set fullname = '$upfullname' where id = '$updateid'");
	$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];
echo $fullname.' <a href="updateefficient.php?upid='.$id.'">Update</a><br>';
}

if (isset($userid)){
	$getsql = $dbh->prepare("select fullname from users where id = '$userid'");
	$getsql->execute();
	$row = $getsql->fetch();
	$fullname = $row[0];
?>
<form action = "updateefficient.php" method="post">
 <input type="hidden" name = "userid" value = "<?php echo $userid;?>">
 <input type="text" name = "upfullname" value = "<?php echo $fullname;?>"><br>
 <input type="submit" name="submit" value = "Edit <?php echo $fullname;?>">
</form>
<?
}
?>