Update Query
Posted: Sun May 26, 2013 5:03 am
Hello Anyone...
I'm gonna make sure if this a good one for updating database...
even the function is work... I'm looking for a good idea...
I'm gonna make sure if this a good one for updating database...
even the function is work... I'm looking for a good idea...
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 "Record has been changed"; } echo"<form method='post' action=''> <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 ORDER BY name ASC"); 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' value='$data[name]' size=20 name='name'/></td></tr> <tr><td>Age: </td><td><input type='text' value='$data[age]' size=20 name='age'/></td></tr> <tr><td>Sex: </td><td><input type='text' value='$data[sex]' size=20 name='sex'/></td></tr> <tr><td>Mobile: </td><td><input type='text' value='$data[mobile]' size=20 name='mobile'/></td></tr> <tr><td colspan=2><input type='submit' value='Submit' name='submitEditForm'/></td></tr> </table></form> "; } } }