i've displayed a table from database using php.and now what i want is to edit records seperately as i've placed an edit and a delete link in front of each record which edits the record from sql.and it is now giving this warning.Please help me to find the error correctly.as iam new to php and sql as well..
this is my code when i click on the edit button in front of any row
<?php include("../includes/config.php"); ?>
<?php
if ($_SESSION["isadmin"])
{
$con=mysql_connect($dbserver,$dbusername,$dbpassword);
if (!$con) { die('Could not connect: ' . mysql_error()); }
mysql_select_db($dbname, $con);
$result = mysql_query("SELECT * FROM accounts WHERE id=".$id."");
while($row = mysql_fetch_array($result))
{
$id=$row['id'];
$firstname = $row['firstname'];
$lastname = $row['lastname'];
$email=$row['email'];
$type=$row['type'];
}
mysql_close($con);
?>
<!DOCTYPE HTML>
<html>
<head>
<title>Edit Teacher</title>
<link rel="StyleSheet" href="../admin/css/style.css" type="text/css" media="screen">
</head>
<body>
<?php include("../admin/includes/header.php"); ?>
<?php include("../admin/includes/nav.php"); ?>
<?php include("../admin/includes/aside.php"); ?>
<div id="maincontent">
<div id="breadcrumbs">
<a href="">Home</a> >
<a href="">Manage Users</a> >
<a href="">List Users</a> >
Edit Teacher
</div>
<h2>Edit Teacher</h2>
<?php
if (isset($_GET["status"]))
{
if ($_GET["status"]==1)
{
echo("<strong>Teacher Has been Successfully Edited!</strong>");
}
}
?>
<form method="post" action="edit-teacher-action.php">
<label>ID:</label><input type="text" value="<?php echo $id; ?>" name="id" />
<label>First Name:</label> <input type="text" value="<?php echo $firstname; ?>" name="Fname" />
<label>Last Name:</label> <input type="text" value="<?php echo $lastname; ?>" name="Lname" />
<label>Email:</label> <input type="text" value="<?php echo $email; ?>" name="email" />
<label>Type:</label> <input type="text" value="<?php echo $type; ?>" name="type" />
<input type="submit" value="Edit" />
</form>
</div>
</body>
<?php include("../admin/includes/footer.php"); ?>
</html>
<?php
}
else
{
header("Location: ".$fullpath."login/unauthorized.php");
}
?>
this is the warning it gives
Notice: Undefined variable: id in C:\xampp\htdocs\project\admin\edit-teacher.php on line 11
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\project\admin\edit-teacher.php on line 14