add option is not working ...... failed to figure out the mistake done..... can anyone help me with it
the code i have is...

PHP Code:
<?php
$con 
mysql_connect("localhost","root","");
if (!
$con) { die('Could not connect: ' mysql_error()); }
$db mysql_select_db("maggot") or die('Could not select DB: ' mysql_error()); 
?>
<html>
<head>
<script type="text/javascript">
function f1(){
var el=document.getElementById("myTable");
// alert(row.nodeName);  // TBODY
var cln = el.lastChild.cloneNode(true);
el.appendChild(cln);
}
function f2(){
var tablo=document.getElementById("myTable");
tablo.removeChild(tablo.lastChild);
}
    var compInfoArray = new Array();
    
    <?php
        $query1 
"SELECT * FROM lab ORDER BY id";
        
$result1 mysql_query($query1) or die(mysql_error());
        
        
// build javascript array
        
while($row1=mysql_fetch_array($result1)){ 
            echo 
'compInfoArray['.$row1['id'].'] = new Array();';
            echo 
'compInfoArray['.$row1['id'].']["test"] = "'.$row1['test'].'";';
            echo 
'compInfoArray['.$row1['id'].']["rate"] = "'.$row1['rate'].'";';
        }
    
?>
    
    function showname() {
        var id = document.form1.id.value;
        document.form1.test.value = compInfoArray[id]["test"];
        document.form1.rate.value = compInfoArray[id]["rate"];
    }
    
    window.onload=function() {
        showname();
    } 
    
</script>

</head>
<body>
    <form name="form1">
    <button onClick="f1()">add</button>
<button onClick="f2()">delete</button>
      <table >
          <tr>
            <td width="100">Select Test</td>
            <td width="170">Test Name</td>
            <td width="100">Test Rate</td>
          </tr>
          </table>
          <table id="myTable">
          <tr>
            <td width="100"><select name="id" onChange="showname()">
              <?php
            $query1 
"SELECT * FROM lab ORDER BY id";
            
$result1 mysql_query($query1) or die(mysql_error());
            
            
// build javascript array
            
while($row1=mysql_fetch_array($result1)){ 
                echo 
'<option value="'.$row1['id'].'">'.$row1['test'].'</option>';
            }
        
?>
            </select></td>
            <td width="100"><input type="text" name="test" value="" /></td>
            <td width="100"><input type="text" name="rate" value="" /></td>
            <td>&nbsp;</td>
        </tr>
      </table>
    </form>
</body>
</html>