I wanted a dropdown box which will display different tables fetched from mysql after selecting options.
so i have this code.

But problem here is when page loads it displays all tables. (It should only display dropdown box.)
and when i choose options from downdown it works well.

what is the problem? pls help thanks.

Code:
<html>
<head>
<script type="text/javascript">
function changeTblDisplay(dhi) { 
  if (dhi == '') { return ; }
  var lee = document.getElementById('statTables').getElementsByTagName('div');
  for (var i=0; i<lee.length; i++) { lee[i].style.display = 'none'; }
  document.getElementById(dhi).style.display = 'block';  
}
</script>
</head>
<body>

<div class="styleit">
<select id="tables" onchange="changeTblDisplay(this.value)">
  <option value="">Choose Table </option>
  <option value="table1"> A </option>
  <option value="table2"> B </option>
  <option value="table3"> C </option>

<option value="table4"> D </option>
<option value="table5"> E </option>
<option value="table6"> F </option>
<option value="table7"> G </option> 
</select>
</div>

<?php

$host = "localhost";

$user = "root";

$pass = "d";

$db = "test"; 

$conne = mysql_connect($host,$user,$pass) or die("couldnot connect");

mysql_select_db($db)or die("unable to connect");

?>
<div id="statTables">

<div id="table1" >
 <table border="1" >
 <thead> <caption> Table 1 </caption> </thead>
<?php

$query = "SELECT * FROM mytable where ram = 'a'";

$result = mysql_query($query);
if(mysql_num_rows($result)>0)
{
	//print rows   
 
                while($row = mysql_fetch_row($result))
                 {
                                 echo "<tr>";
                                  
                                 echo "<td>".$row[1]."</td>";
                                 echo "<td>".$row[2]."</td>";
                                 echo "<td>".$row[3]."</td>";
                                 echo "<td>".$row[4]."</td>";
 
                                 echo "</tr>";
                                            
                 }
                 echo "</table>";
}
else {echo "no result found";}
?>
</div>

<div id="table2" >
 <table border="1" >
 <thead> <caption> Table 2 </caption> </thead>
<?php

$query = "SELECT * FROM mytable where ram = 'b'";

$result = mysql_query($query);
if(mysql_num_rows($result)>0)
{
	//print rows   
 
                while($row = mysql_fetch_row($result))
                 {
                                 echo "<tr>";
                                  
                                 echo "<td>".$row[1]."</td>";
                                 echo "<td>".$row[2]."</td>";
                                 echo "<td>".$row[3]."</td>";
                                 echo "<td>".$row[4]."</td>";
 
                                 echo "</tr>";
                                            
                 }
                 echo "</table>";
}
else {echo "no result found";}
?>
</div>

<div id="table3" >
 <table border="1" >
 <thead> <caption> Table3 </caption> </thead>
<?php

$query = "SELECT * FROM mytable where ram = 'c'";

$result = mysql_query($query);
if(mysql_num_rows($result)>0)
{
	//print rows   
 
                while($row = mysql_fetch_row($result))
                 {
                                 echo "<tr>";
                                  
                                 echo "<td>".$row[1]."</td>";
                                 echo "<td>".$row[2]."</td>";
                                 echo "<td>".$row[3]."</td>";
                                 echo "<td>".$row[4]."</td>";
 
                                 echo "</tr>";
                                            
                 }
                 echo "</table>";
}
else {echo "no result found";}
?>
</div>

<div id="table4" >
 <table border="1" >
 <thead> <caption> table4 </caption> </thead>
<?php

$query = "SELECT * FROM mytable where ram = 'd'";

$result = mysql_query($query);
if(mysql_num_rows($result)>0)
{
	//print rows   
 
                while($row = mysql_fetch_row($result))
                 {
                                 echo "<tr>";
                                  
                                 echo "<td>".$row[1]."</td>";
                                 echo "<td>".$row[2]."</td>";
                                 echo "<td>".$row[3]."</td>";
                                 echo "<td>".$row[4]."</td>";
 
                                 echo "</tr>";
                                            
                 }
                 echo "</table>";
}
else {echo "no result found";}
?>
</div>

<div id="table5" >
 <table border="1" >
 <thead> <caption> Table5 </caption> </thead>
<?php

$query = "SELECT * FROM mytable where ram = 'e'";

$result = mysql_query($query);
if(mysql_num_rows($result)>0)
{
	//print rows   
 
                while($row = mysql_fetch_row($result))
                 {
                                 echo "<tr>";
                                  
                                 echo "<td>".$row[1]."</td>";
                                 echo "<td>".$row[2]."</td>";
                                 echo "<td>".$row[3]."</td>";
                                 echo "<td>".$row[4]."</td>";
 
                                 echo "</tr>";
                                            
                 }
                 echo "</table>";
}
else {echo "no result found";}
?>
</div>

<div id="table6" >
 <table border="1" >
 <thead> <caption> Table6 </caption> </thead>
<?php

$query = "SELECT * FROM mytable where ram = 'f'";

$result = mysql_query($query);
if(mysql_num_rows($result)>0)
{
	//print rows   
 
                while($row = mysql_fetch_row($result))
                 {
                                 echo "<tr>";
                                  
                                 echo "<td>".$row[1]."</td>";
                                 echo "<td>".$row[2]."</td>";
                                 echo "<td>".$row[3]."</td>";
                                 echo "<td>".$row[4]."</td>";
 
                                 echo "</tr>";
                                            
                 }
                 echo "</table>";
}
else {echo "no result found";}
?>
</div>

<div id="table7" >
 <table border="1" >
 <thead> <caption>Table7 </caption> </thead>
<?php

$query = "SELECT * FROM mytable where ram = 'g'";

$result = mysql_query($query);
if(mysql_num_rows($result)>0)
{
	//print rows   
 
                while($row = mysql_fetch_row($result))
                 {
                                 echo "<tr>";
                                  
                                 echo "<td>".$row[1]."</td>";
                                 echo "<td>".$row[2]."</td>";
                                 echo "<td>".$row[3]."</td>";
                                 echo "<td>".$row[4]."</td>";
 
                                 echo "</tr>";
                                            
                 }
                 echo "</table>";
}
else {echo "no result found";}
?>
</div>

</div>
</body>
</html>