This code is to update the record into the database. Assuming there's a record that you want to edit, when you submit the button the page looks nothing happened because you need to refresh the page before appear the output here's the code. Help me guys pls...

sorry for my grammar i hope you understand guys :icon_cheesygrin:

<?php
$con = mysql_connect("localhost","root","");
$sql = mysql_select_db("luweegee",$con);
?>
<html>
<head><link rel='stylesheet' type='text/css' href='Style.css'/></head>
	  <body>
	  <table border=0 align='center' width=900 cellpadding=20 cellspacing=0>
	  <tr><td  class='title' colspan=2><h1>Update Record</h1></td></tr>

		<tr>
		<td class='borderBaba' colspan=2></td>
		</tr>
	  
<tr>
<td class='form' valign='top'>
<ul>
<a class='navigation' href='View.php'><li>View Record</li></a>
<a class='navigation' href='Add.php'><li>Add Record</li></a>	
<a class='navigation' href='Edit.php'><li>Edit Record</li></a>
<a class='navigation' href='Delete.php'><li>Delete Record</li></a>
</u>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
</td>


<td class='Addstyles' valign='top'>
<table class='Addstyle' border=0 width=550 cellpadding=5 cellspacing=0>

<?php
echo"<form method='post' action='Edit.php'>
<tr>
		<td  class='viewTable1'><center>Name</center></td>
		<td  class='viewTable1'><center>Age</center></td>
		<td  class='viewTable1'><center>Sex</center></td>
		<td  class='viewTable1'><center>Mobile</center></td>
		<td  class='viewTable1'><center>Action</center></td>
</tr>
		";
	$sel = mysql_query("SELECT * FROM resume");
	while($data=mysql_fetch_array($sel))
		{
		echo "<tr>
				<td ><center>$data[name]</center></td>
				<td><center>$data[age]</center></td>
				<td><center>$data[sex]</center></td>
				<td><center>$data[mobile]</center></td>
				<td><center><input type='submit' value='Update' name='updateButt$data[id]'></center></td>
			  </tr>";
		}
	
	echo "</table></form>";
echo "<br><BR>";

		for($x=0;$x<=100;$x++)
		{
			if($_POST[updateButt.$x])
			{
			$select = mysql_query("SELECT * FROM resume WHERE id=$x");
				while($data=mysql_fetch_array($select))
				{
					echo "
					<form name='myform' method='post' action='Edit.php'>
					<table border=0 cellspacing=0 align='center' class='Addstyle'>
	<tr><td align='right' class='viewTable5' colspan=2><div class='textfile'>Editing: <span class='underline'>$data[name]</span></div></td></tr>
					<input size=20 type='hidden' value=$data[id] name='idnumber'>	
					<tr><td>Name: </td><td><input type='text' size=20 name='name'/></td></tr>
					<tr><td>Age: </td><td><input type='text' size=20 name='age'/></td></tr>
					<tr><td>Sex: </td><td><input type='text' size=20 name='sex'/></td></tr>
					<tr><td>Mobile: </td><td><input type='text' size=20 name='mobile'/></td></tr>
					<tr><td colspan=2><input type='submit' value='Submit' name='submitEditForm'/></td></tr>

				</table></form>
				";		
				}
			}
		}
		
		if($_POST['submitEditForm'])
		{
	$update = mysql_query("UPDATE resume SET name='$_POST[name]', age='$_POST[age]', sex='$_POST[sex]', mobile='$_POST[mobile]' WHERE id='$_POST[idnumber]'");
		}
	
?>
</td>
</tr>
<tr>
<td class='borderBaba' colspan=2 align='center'>
<br>Copyright 2011 ©  All Rights Reserved<br><br>
</tr>
</td>
</table>
</body>
</html>

When you submit the form, the site refreshes and gets the $_POST but after updating it will not refresh automaticly, so the updates will not be shown. You could just let PHP refresh the page after updating:

if($_POST['submitEditForm'])
		{
	$update = mysql_query("UPDATE resume SET name='$_POST[name]', age='$_POST[age]', sex='$_POST[sex]', mobile='$_POST[mobile]' WHERE id='$_POST[idnumber]'");
header('Location: edit.php');
		}

Just put your update query at the top, so when the page was load, the script update first the record and then display the result.

Try the code below.

<?php
$con = mysql_connect("localhost","root","");

$sql = mysql_select_db("luweegee",$con);
?>
<html>
<head><link rel='stylesheet' type='text/css' href='Style.css'/></head>
	  <body>
	  <table border=0 align='center' width=900 cellpadding=20 cellspacing=0>
	  <tr><td  class='title' colspan=2><h1>Update Record</h1></td></tr>
 
		<tr>
		<td class='borderBaba' colspan=2></td>
		</tr>
 
<tr>
<td class='form' valign='top'>
<ul>
<a class='navigation' href='View.php'><li>View Record</li></a>
<a class='navigation' href='Add.php'><li>Add Record</li></a>	
<a class='navigation' href='Edit.php'><li>Edit Record</li></a>
<a class='navigation' href='Delete.php'><li>Delete Record</li></a>
</u>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
</td>
 
 
<td class='Addstyles' valign='top'>
<table class='Addstyle' border=0 width=550 cellpadding=5 cellspacing=0>
 
<?php
// put the update query here.

if($_POST['submitEditForm'])
{
	$update = mysql_query("UPDATE resume SET name='$_POST[name]', age='$_POST[age]', sex='$_POST[sex]', mobile='$_POST[mobile]' WHERE id='$_POST[idnumber]'");
		}
echo"<form method='post' action='Edit.php'>
<tr>
		<td  class='viewTable1'><center>Name</center></td>
		<td  class='viewTable1'><center>Age</center></td>
		<td  class='viewTable1'><center>Sex</center></td>
		<td  class='viewTable1'><center>Mobile</center></td>
		<td  class='viewTable1'><center>Action</center></td>
</tr>
		";
	$sel = mysql_query("SELECT * FROM resume");
	while($data=mysql_fetch_array($sel))
		{
		echo "<tr>
				<td ><center>$data[name]</center></td>
				<td><center>$data[age]</center></td>
				<td><center>$data[sex]</center></td>
				<td><center>$data[mobile]</center></td>
				<td><center><input type='submit' value='Update' name='updateButt$data[id]'></center></td>
			  </tr>";
		}
 
	echo "</table></form>";
echo "<br><BR>";
 
		for($x=0;$x<=100;$x++)
		{
			if($_POST[updateButt.$x])
			{
			$select = mysql_query("SELECT * FROM resume WHERE id=$x");
				while($data=mysql_fetch_array($select))
				{
					echo "
					<form name='myform' method='post' action='Edit.php'>
					<table border=0 cellspacing=0 align='center' class='Addstyle'>
	<tr><td align='right' class='viewTable5' colspan=2><div class='textfile'>Editing: <span class='underline'>$data[name]</span></div></td></tr>
					<input size=20 type='hidden' value=$data[id] name='idnumber'>	
					<tr><td>Name: </td><td><input type='text' size=20 name='name'/></td></tr>
					<tr><td>Age: </td><td><input type='text' size=20 name='age'/></td></tr>
					<tr><td>Sex: </td><td><input type='text' size=20 name='sex'/></td></tr>
					<tr><td>Mobile: </td><td><input type='text' size=20 name='mobile'/></td></tr>
					<tr><td colspan=2><input type='submit' value='Submit' name='submitEditForm'/></td></tr>
 
				</table></form>
				";		
				}
			}
		}
 
		
 
?>
</td>
</tr>
<tr>
<td class='borderBaba' colspan=2 align='center'>
<br>Copyright 2011 ©  All Rights Reserved<br><br>
</tr>
</td>
</table>
</body>
</html>

oh okay, thats better xD

@lyrico thanks it works... ^^

You can now mark this threads as solved ^^,

how can mark this threads as a solved?

You can found that at the top of the comment text area. There a header "Has this thread been answered", just click "Mark this thread as solved" (underlined text).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.