Jump to content

UPDATE never completes


pobz

Recommended Posts

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]

Link to comment
https://forums.phpfreaks.com/topic/199954-update-never-completes/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.