pobz Posted April 27, 2010 Share Posted April 27, 2010 I am after some help please, I'm struggling to see whats wrong with the code. The SELECT calls down all the rows in the table and the HTML output allows me to edit the data but when clicking submit the UPDATE doesn't seem to complete it just refreshes the page and never uploads the amended data. <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title></title> <link rel="stylesheet" type="text/css" href="../../main.css" /> </head> <body class="iframe"> <h2>Update Instructor Database</h2><br> <?php include("dbinfo.inc.php"); mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM ContactTable"; $result=mysql_query($query); // Count table rows $count=mysql_num_rows($result); ?> <table border="0" cellspacing="1" cellpadding="0"> <form name="form1" method="post" action=""> <tr> <td> <table border="0" cellspacing="1" cellpadding="0"> <tr> <th class="list">Id</th> <th class="list">First Name</th> <th class="list">Last Name</th> <th class="list">School Name</th> <th class="list">Phone Number</th> <th class="list">Mobile Number</th> <th class="list">Sex</th> <th class="list">Car</th> <th class="list">PP Course</th> <th class="list">Int Course</th> <th class="list">Email</th> <th class="list">Website</th> </tr> <?php while($rows=mysql_fetch_array($result)){ ?> <tr> <td class="list"><? $id[]=$rows['id']; ?><? echo $rows['id']; ?></td> <td class="list"><input name="FName[]" type="text" id="FName" value="<? echo $rows['FName']; ?>"></td> <td class="list"><input name="LName[]" type="text" id="LName" value="<? echo $rows['LName']; ?>"></td> <td class="list"><input name="SName[]" type="text" id="SName" value="<? echo $rows['SName']; ?>"></td> <td class="list"><input name="PHON[]" type="text" id="PHON" value="<? echo $rows['PHON']; ?>"></td> <td class="list"><input name="PHONM[]" type="text" id="PHONM" value="<? echo $rows['PHONM']; ?>"></td> <td class="list"><input name="Sex[]" type="text" id="Sex" value="<? echo $rows['Sex']; ?>"></td> <td class="list"><input name="Car[]" type="text" id="Car" value="<? echo $rows['Car']; ?>"></td> <td class="list"><input name="Course1[]" type="text" id="Course1" value="<? echo $rows['Course1']; ?>"></td> <td class="list"><input name="Course2[]" type="text" id="Course2" value="<? echo $rows['Course2']; ?>"></td> <td class="list"><input name="Email[]" type="text" id="Email" value="<? echo $rows['Email']; ?>"></td> <td class="list"><input name="Website[]" type="text" id="Website" value="<? echo $rows['Website']; ?>"></td> </tr> <?php } ?> <tr> <td colspan="12" align="left"><input type="submit" name="Submit" value="Update"></td> </tr> </table> </td> </tr> </form> </table> <?php // Check if button name "Submit" is active, do this if($Submit){ for($i=0;$i<$count;$i++){ $query1="UPDATE ContatctTable SET `FName`='$FName[$i]', `LName`='$LName[$i]', `SName`='$SName[$i]', `PHON`='$PHON[$i]', `PHONM`='$PHONM[$i]', `Sex`='$Sex[$i]', `Car`='$Car[$i]', `Course1`='$Course1[$i]', `Course2`='$Course2[$i]', `Email`='$Email[$i]', `Website`='$Website[$i]' WHERE id='$id[$i]'"; mysql_query($query1); echo "Record Updated"; echo '<br /><br /><a href="update.php">Update Another Instructor</a>'; } } mysql_close(); ?> </body> </html> [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/199954-update-never-completes/ Share on other sites More sharing options...
Ken2k7 Posted April 27, 2010 Share Posted April 27, 2010 You have a lot of undefined variables in the context of your code like $Submit, $FName, $LName etc. Quote Link to comment https://forums.phpfreaks.com/topic/199954-update-never-completes/#findComment-1049513 Share on other sites More sharing options...
fenway Posted April 28, 2010 Share Posted April 28, 2010 And no one asked you to post the code regarldess. Quote Link to comment https://forums.phpfreaks.com/topic/199954-update-never-completes/#findComment-1050139 Share on other sites More sharing options...
Ken2k7 Posted April 29, 2010 Share Posted April 29, 2010 And no one asked you to post the code regarldess. I know that's not directed towards me, but what does that mean? Quote Link to comment https://forums.phpfreaks.com/topic/199954-update-never-completes/#findComment-1050499 Share on other sites More sharing options...
jdavidbakr Posted April 29, 2010 Share Posted April 29, 2010 Try echoing your query instead of executing it - that may lead you to what is happening. Quote Link to comment https://forums.phpfreaks.com/topic/199954-update-never-completes/#findComment-1050609 Share on other sites More sharing options...
fenway Posted May 1, 2010 Share Posted May 1, 2010 And no one asked you to post the code regarldess. I know that's not directed towards me, but what does that mean? It means that blindly posting entire scripts doesn't help anyone help the OP. Quote Link to comment https://forums.phpfreaks.com/topic/199954-update-never-completes/#findComment-1051534 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.