Hi, I have a table that when operator insert an Id and want to edit data ,he can add new data also.i have a problem with this scripts ,can anyone edit my script or help me? thanks
My Scripts that Not Complated because i begin learn php for afew weeks and i dont know how do it : config: <?php $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = ''; $dbname = 'Array'; $connect = mysql_connect ($dbhost, $dbuser, $dbpass) OR die (mysql_erorr()); mysql_select_db ($dbname, $connect)OR die (mysql_erorr()); ?> PHP: Add_Edit_Form.php: <html> <head> <link href="style.css" rel="stylesheet"> </head> <body> <table align="center" id="tablet" width="27%" > <tr> <td id="main">Enter Your Id And Click Add_EDIT </td> </tr> <tr> <td class='text'><form method='POST' action='Add_Edit.php'><p align='center'> Your ID :<input type="text" name="Id" size="5"> <input type='submit' value='Add_EDIT' class='btn'></p> </form></td> </tr> </table> </form> </table> PHP: Add_Edit.php: html> <head> <link href="style.css" rel="stylesheet"> <title> Learn : Array </title> </head> <body> <table width="55%" align="center" cellspacing="1" id="tablet" > <tr> <td id="main">Name</td> <td id="main">Family</td> <td id="main">City</td> <td id="main">Country</td> </tr> <?php include"config.php"; $query=mysql_query("SELECT * FROM `learn` WHERE Id='$_POST[Id]' "); while($row=mysql_fetch_array($query)){ $Number=$row[Number]; $Id=$row[Id]; $Name=$row[Name]; $Family=$row[Family]; $City=$row[City]; $Country=$row[Country]; echo ('<form method="POST" action="MkeditId.php">');?> <tr> <input type='hidden' name='Number[]' value="<?php echo"$Number";?>"</td></td> <input type='hidden' name='Id[]' value="<?php echo"$Id";?>"</td></td> <td id='tmain'><input type='text' name='Name[]' value="<?php echo"$Name";?>"</td> <td id='tmain'><input type='text' name='Family[]' value="<?php echo"$Family";?>"</td> <td id='tmain'><input type='text' name='City[]' value="<?php echo"$City";?>"</td> <td id='tmain'><input type='text' name='Country[]' value="<?php echo"$Country";?>"</td> </tr> <?php } ?> <tr> <td id='tmain'><input type='text' name='Name[]' ></td> <td id='tmain'><input type='text' name='Family[]' ></td> <td id='tmain'><input type='text' name='City[]'> </td> <td id='tmain'><input type='text' name='Country[]' ></td> </tr> <tr> <td id='tmain'><input type='text' name='Name[]'> </td> <td id='tmain'><input type='text' name='Family[]' ></td> <td id='tmain'><input type='text' name='City[]' ></td> <td id='tmain'><input type='text' name='Country[]' ></td> </tr> <?php echo('<table width="35%" border="0" align="center" ><tr><div align="center"><input type="submit" value="Add_Edit" name="B1" class="btn"><input type="reset" value="Reset" class="btn"></p> </tr></form>'); ?> PHP: MkediId.php: <?php include "config.php"; $Data =array( n=>($_POST['Number']),i=>($_POST['Id']),na=>($_POST['Name']),f=>($_POST['Family']),c=>($_POST['City']),co=>($_POST['Country'])); $Howmany=count($_POST['Name']); $i=0; while($i<$Howmany) { $Number=$Data["n"][$i]; $Id=$Data["i"][$i]; $Name=$Data["na"][$i]; $Family=$Data["f"][$i]; $City=$Data["c"][$i]; $Country=$Data["co"][$i]; $EditData = "UPDATE `learn` SET Name='$Name', Family= '$Family',city='$City',country='$Country' where Number='$Number' "; $result = mysql_query($EditData) or die(mysql_error()); $i++; } if($EditData){ echo "<p class='text'>Your data is Edit Sucsesfull"; } else{ echo "<p class='text'>There Is a Problem.Please Try Again"; } ?> PHP: