I can't query my database and cannot update, may I know what is the mistake in my coding?
<html>
<head>
<title>Index</title>
</head>
<div style="position: absolute; width: 1146px; height: 842px; z-index: 1; left:10px; top:1px" id="layer2" align="center">
<body background="E-Filing%20Management%20System%20Picture/Snow.gif">
<p align="center">
<img border="0" src="E-Filing%20Management%20System%20Picture/logo-RR-gif.gif" width="957" height="245"></p>
<p align="center"><span lang="zh-cn"> </span></p>
<p align="center"><span lang="zh-cn"><img border="0" src="E-Filing%20Management%20System%20Picture/Association.gif" width="491" height="74"></span></p>
<p align="center"><span lang="zh-cn"> </span></p>
<form method="post" action="AssociationEdit.php">
<?php
$connection = mysql_connect("localhost", "root", "")
or die("<font color='#FFFFFF'>Could not connect to MySQL </font>" .mysql_error() );
$selection = mysql_select_db("efiling")
or die("<font color='#FFFFFF'>Unable to select database. </font>" .mysql_error());
echo "<font size='4' face='Arial Rounded MT Bold'><font color='#FFFFFF'><span lang='en-us'>Please select a group : </font></span>";
echo"<select name='an'>";
echo "<option>---Please Select---</option>";
echo "<option value='A - H' selected>A - H</option>";
echo "<option value ='I - Q'>I - Q</option>";
echo "<option value ='R - Z'>R - Z</option>";
echo "</select>  ";
echo "<input type='submit' name='submit' value='Proceed'>";
if(isset($_POST["submit"]))
{
$an = $_POST["an"];
$submit = $_POST["submit"];
if($submit=="proceed")
{
$connection = mysql_connect("localhost", "root", "")
or die("<font color='#FFFFFF'>Could not connect to MySQL</font>" .mysql_error() );
$selection = mysql_select_db("efiling")
or die("<font color='#FFFFFF'>Unable to select database.</font>" .mysql_error());
if(isset($_POST['an']))
{
$an=$_POST["an"];
if($an == "A - G")
{
$sql = "SELECT * from association Where AssociationName BETWEEN 'A%' AND 'H%' ORDER BY AssociationName";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
echo "<p>";
echo "ID : <input type='text' name='id1' value='$row[ID]' size='40'><br>";
echo "Association Name : <input type='text' name='an1' value='$row[AssociationName]' size='40'><br>";
echo "<input type='submit' name='submit' value='update'>";
}
else if($an == "H - Q")
{
$sql = "SELECT * from association Where AssociationName BETWEEN 'H%' AND 'R%' ORDER BY AssociationName";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
echo "<p>";
echo "ID : <input type='text' name='id2' value='$row[ID]' size='40'><br>";
echo "Association Name : <input type='text' name='an2' value='$row[AssociationName]' size='40'><br>";
echo "<input type='submit' name='submit' value='update'>";
}
else if($an == "R - Z")
{
$sql = "SELECT * from association Where AssociationName BETWEEN 'R%' AND 'Z%' OR AssociationName LIKE 'Z%' ORDER BY AssociationName";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
echo "<p>";
echo "ID : <input type='text' name='id3' value='$row[ID]' size='40'><br>";
echo "Association Name : <input type='text' name='an3' value='$row[AssociationName]' size='40'><br>";
echo "<input type='submit' name='submit' value='update'>";
}
}
}
if($submit=="update")
{
$id1 = $_POST["id1"];
$an1 = $_POST["an1"];
$id2 = $_POST["id2"];
$an2 = $_POST["an2"];
$id3 = $_POST["id3"];
$an3 = $_POST["an3"];
$sql = "UPDATE association SET AssociationName = '$an1''$an2''$an3', ID = '$'id1' '$'id2' '$'id3'";
$result = mysql_query($sql);
if (mysql_num_rows($result2) < 1)
{
echo "<hr><h2>Record Updated</h2>";
}
else
{
print"<p align='center'> </p>
<table width='400' height='200' border='1' align='center' bordercolor='#66FF00'bgcolor='#0000FF'>
<td><div align='center'><font color='#FF0000' size='5'><p>The Association Name Has Been Registered, Please Enter Other Association Name</p> </font></div></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table> ";
print "<p align='center'> </p>";
echo "<HTML><META HTTP-EQUIV='REFRESH' CONTENT='2; URL=AssociationAdd.php'>
<CENTER><p> </p><p>
<tr>
<td align='center'><h12>please wait...</h12></td>
</tr>
</table><p> </p><p> </p></CENTER></BODY></HTML>";
}
}
}
?>
</form>
<p align="center"> </p>
<p align="center"> </p>
<p align="center"> </p>
<p align="center"> </p>
<p align="center"> </p>
</div>
</body>
</html>