combobox problems

Thread Solved

Join Date: Oct 2007
Posts: 40
Reputation: rohitrohitrohit is an unknown quantity at this point 
Solved Threads: 2
rohitrohitrohit's Avatar
rohitrohitrohit rohitrohitrohit is offline Offline
Light Poster

combobox problems

 
1
  #1
Sep 23rd, 2008
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 ->http://localhost/MIS/PS/add/add_ps2.php?name=champawat.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
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 1,072
Reputation: Shanti Chepuru is on a distinguished road 
Solved Threads: 98
Shanti Chepuru's Avatar
Shanti Chepuru Shanti Chepuru is offline Offline
Veteran Poster

Re: combobox problems

 
0
  #2
Sep 23rd, 2008
Please use code tags...
Be intelligent, But Don't try to cheat.. Be innocent But Don't get cheated..
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,463
Reputation: cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about 
Solved Threads: 136
cwarn23's Avatar
cwarn23 cwarn23 is offline Offline
Nearly a Posting Virtuoso

Re: combobox problems

 
0
  #3
Sep 23rd, 2008
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.
  1. $res = mysql_query("SELECT distinct untcode FROM table where division='$division'")
  2. or die("Invalid query: " . mysql_query());
So basically replace the above with the below.
  1. $res = mysql_query("SELECT `distinct untcode` FROM `table` where `division`='".$division."'")
  2. or die("Invalid query: " . mysql_error());
or if the words 'distinct' and 'untcode' are two separate columns then use the following:
  1. $res = mysql_query("SELECT `distinct`, `untcode` FROM `table` where `division`='".$division."'")
  2. 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.
Try not to bump 10 year old threads as it can be really annoying.
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC