hi...........
my update code is working correcty.... .....but i want update links in front of every record of table ... plz tell me how it is possible...........
thanx for last reply..... m pretty new in php
[file name=updaterecord.php]
<?
$con=mysql_connect('localhost','root','root');
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("test", $con);
// ***** This part will process when you Click on "Submit" button *****
// Check, if you clicked "Submit" button
if($_POST['Submit']){
// Get parameters from form.
$FirstName=$_POST['FirstName'];
$LastName=$_POST['LastName'];
$Age=$_POST['Age'];
//$tel=$_POST['tel'];
// Do update statement.
mysql_query("update student set FirstName='$FirstName', LastName='$LastName', Age='$Age' where FirstName='$FirstName'");
// Re-direct this page to select.php.
header("location:select1.php");
exit;
}
$FirstName=$_GET['FirstName'];
// Get records in all columns from table where column id equal in $id and put it in $result.
$result=mysql_query("select * from student where FirstName='$FirstName'");
// Split records in $result by table rows and put them in $row.
$row=mysql_fetch_assoc($result);
// Close database connection.
mysql_close($con);
?>
<!-- END OF PHP CODES AND START HTML TAGS -->
<html>
<body>
<!-- set this form to POST method and target this form to itself ($PHP_SELF;)-->
<form name="form1" method="post" action="<? echo $PHP_SELF; ?>">
<p>FirstName :
<input name="FirstName" type="text" value="<? echo $row['FirstName']; ?>"/>
<br />
Last Name :
<!-- name of this text field is "email" -->
<input name="LastName" type="text" value="<? echo $row['LastName']; ?>"/>
<br />
Age :
<!-- name of this text field is "tel" -->
<input name="Age" type="text" value="<? echo $row['Age']; ?>"/>
</p>
<p>
<input type="submit" name="Submit" value="Submit" />
</p>
</form>
</body>
</html>
//select.php
<html>
<body bgcolor="pink">
<?
$con=mysql_connect("localhost","root","root");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("test", $con);
$result=mysql_query("select * from student");
echo "<table border='3'> <BR><BR><BR><BR>
<tr>
<th >Firstname</th>
<th>Lastname</th>
<th> Age</th>
</tr>" ;
while($row=mysql_fetch_assoc($result))
{
echo "<tr>";
echo "<td>" . $row['FirstName'] . "</td>";
echo "<td>" . $row['LastName'] . "</td>";
echo "<td>" . $row['Age']. "</td>";
echo "</tr>";
echo '<a href="updatecode.php?FirstName='.$row['FirstName'].' ">Update</a> ' ;
}
mysql_close($con);
?>
</body></html>