0

I cant update my data i know theres something wrong in my code...pls help me guys i need this code ASAP... :(

<?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=7 cellspacing=0>

<?php
echo"
<tr>
		<td><center>Name</center></td>
		<td><center>Age</center></td>
		<td><center>Sex</center></td>
		<td><center>Mobile</center></td>
		<td><center>Action</center></td>
</tr>
		<form method='post' action='Edit.php'>";
	
	$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 "</form>";

		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>				
					<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>

				</form>
				";		
				}
			}
		}
		
		if($_POST['submitEditForm'])
		{
	$update = mysql_query("UPDATE resume SET name='".$_POST["name".$id]."', age='".$_POST["age".$id]."', sex='".$_POST["sex".$id]."', mobile='".$_POST["mobile".$id]."' WHERE id='".$id."'");
		
		}
	
?>

</table>
<tr>
<td class='borderBaba' colspan=2 align='center'>
<br>Copyright 2011 ©  All Rights Reserved<br><br>
</tr>
</td>
</table>
</body>
</html>
2
Contributors
5
Replies
6
Views
6 Years
Discussion Span
Last Post by luweegee
0

Try this update query;

mysql_query("UPDATE resume SET resume.name='$_POST[name]' WHERE id='".$id."')";
mysql_query("UPDATE resume SET resume.age='$_POST[age]' WHERE id='".$id."')";
mysql_query("UPDATE resume SET resume.mobile='$_POST[mobile]' WHERE id='".$id."')";
mysql_query("UPDATE resume SET resume.sex='$_POST[sex]' WHERE id='".$id."')";
0

can anyone help me pls....im runnning out of time this is my project help me please im going crazy....i try all the query but nothings happen....im feel so no0bs

1

I'm not sure but I think the problem is that you did not define what is $id in your update query.

//if the user press the submitEditForm, where is the $id?
if($_POST['submitEditForm'])
{
// maybe you need here something like...
$id=$_POST['id'];
$update = mysql_query("UPDATE resume SET name='".$_POST["name".$id]."', age='".$_POST["age".$id]."', sex='".$_POST["sex".$id]."', mobile='".$_POST["mobile".$id]."' WHERE id='".$id."'");
 }

In your code, the script can not identify what record you want to update. Also, I'm not sure if your update query is correct. I mean, this is the first time I saw that kind of update query. Try to declare the value of $id and try to use my suggested update query. Since your activity is urgent, I think this is the last help i can offer for today.

0

YESSSSSSSSSSSSSSSSSSSSSSSSSS.... @lyrico goodjob ur code is working.... after 1 day the problem is solved....

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.