943,905 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 2924
  • PHP RSS
Sep 23rd, 2008
1

combobox problems

Expand Post »
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
Similar Threads
Reputation Points: 15
Solved Threads: 5
Junior Poster
rohitrohitrohit is offline Offline
120 posts
since Oct 2007
Sep 23rd, 2008
0

Re: combobox problems

Please use code tags...
Reputation Points: 137
Solved Threads: 162
Posting Virtuoso
Shanti C is offline Offline
1,641 posts
since Jul 2008
Sep 23rd, 2008
0

Re: combobox problems

Quote ...
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.
php Syntax (Toggle Plain Text)
  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.
php Syntax (Toggle Plain Text)
  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:
php Syntax (Toggle Plain Text)
  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.
Sponsor
Featured Poster
Reputation Points: 410
Solved Threads: 258
Occupation: Genius
cwarn23 is offline Offline
3,004 posts
since Sep 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: ttf font uploading problem?
Next Thread in PHP Forum Timeline: Error in uploading file via ftp server





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC