new to this php..

i have a login page.

   <form name="form" id="form" action="aa.php" method="post">
      ...
       <input name="txtusername" id="txtusername" type="text" width="70px" class="style23"/>
      <input name="txtpass" type="password" width="70px" class="style23"/>
...... button here...
       </form>

after login i am getting login name of user form URl ->[url]http://localhost/MIS/PS/add/add_ps2.php?[/url][B]name=champawat.[/B] in second page i hva three combobox(unit,achivements,crop). the data they containing fetch form mysql on the basis of login name entered. i am fetching unit form mysql below code....

<?php    
  $d=$_GET['loginname'];

  $res = mysql_query("SELECT distinct untcode FROM table where division='$division'")
  or die("Invalid query: " . mysql_query());
  echo '<select class="style23" id="unt" name="unt" onchange="sel()">';
  echo '<option value="">Select..</option>';
  while ($row = mysql_fetch_array($res)) 
  {
         $va1 = $row['untcode'];
         if(isset($_POST['unt']) )
         { 
            if($va1==$_POST['unt'])
            {
                echo "<option value='$va1' selected>$va1</option>";
            }
            else
            {
                echo "<option value='$va1'>$va1</option>";
            }
        }
        else
         {  
            echo "<option value='$va1'>$va1</option>";
         }  
    }
echo '</select>';
?>

when user select his unit corresponding value again fetch form mysql and fill to other combobox but onchange() my browers url change http://localhost/MIS/PS/add/add_ps2.php and other combobox value are not fetching form mysql. i make a function sel() <document.form.submit()> onchange combobox item.but problem is not solving
please help me form rohit

Shanti C commented: use code tags.... +2

Please use code tags...

when user select his unit corresponding value again fetch form mysql and fill to other combobox but onchange() my browers url change http://localhost/MIS/PS/add/add_ps2.php and other combobox value are not fetching form mysql. i make a function sel() <document.form.submit()> onchange combobox item.but problem is not solving
please help me form rohit

Although the information in that quote is hard to understand (a bit fragmented), I can spot several things wrong with the below mysql query. One is you have a bug in the debugger, that is the last line of the below code and the variable in the mysql query needs the appropriate surrounding code so the script searches for the value of the variable instead of the name of the variable.

$res = mysql_query("SELECT distinct untcode FROM table where division='$division'")
or die("Invalid query: " . mysql_query());

So basically replace the above with the below.

$res = mysql_query("SELECT `distinct untcode` FROM `table` where `division`='".$division."'")
or die("Invalid query: " . mysql_error());

or if the words 'distinct' and 'untcode' are two separate columns then use the following:

$res = mysql_query("SELECT `distinct`, `untcode` FROM `table` where `division`='".$division."'")
or die("Invalid query: " . mysql_error());

So the above is what I have notices without fully understanding the problem although you did describe what is happening ok.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.