I am trying to get my database to display in a form using this code below. The problem is, the form (textfield) is not displaying anything. Can someone give me a hint?
<?php
session_start();
if (!isset($_SESSION['memberusername'])){
header("Location: contractorlogin.php");
exit();
}
mysql_connect('localhost','xxx','xxxxxx') or die( mysql_error() );
mysql_select_db('xxxxx') or die( mysql_error() );
$user = mysql_real_escape_string($_SESSION['memberusername']);
$sql = "SELECT Username FROM contractors WHERE Username='" . $user . "'";
$result = mysql_query($sql) or die( 'Unable to execute<br>'.$sql.'<br>'.mysql_error());
if( !mysql_num_rows($result) )
{
echo '<p>No Records found!</p>';
}
else
{
$row=mysql_fetch_assoc($result);
echo '<table><tr><th>' .implode('</th><th>', array_keys($row) ).'</th></tr>';
do
{
echo '<tr><td>'.implode('</td><td>',$row).'</td></tr>';
}while($row=mysql_fetch_assoc($result));
echo '</table>';
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<form action="<?php $_SERVER['PHP_SELF']?> " method="post" enctype="multipart/form-data">
<input type="text" name="myname" value="<?php echo $row['name']?>">
<input type="submit" name="submit" value="Update">
</form>
</body>
</html>