Jump to content

Option Select


JDPerry

Recommended Posts

I have set up two drop down boxes on a form and when I submit the form the values that are passed
are the last values in the list, not the selected value. What is the proper code to pass the selected variables.

[!--coloro:#FF6666--][span style=\"color:#FF6666\"][!--/coloro--]
This is the selection[!--colorc--][/span][!--/colorc--]
//Create a selection list for the UserInfo table
echo "<select name = 'EmpNum'>\n";
echo "<option value = '0'>Select a User\n";

//Retreive data until all results collected from UserInfo
while($row = mysql_fetch_array($result))
{
extract($row);
echo "<option value = $EmpNum>$Fname $Lname\n";
}
echo "</select>\n";
echo "<br></br>";
echo "</td>";

[!--coloro:#FF6666--][span style=\"color:#FF6666\"][!--/coloro--]This is how I am trying to pass it[!--colorc--][/span][!--/colorc--]
print ("<INPUT TYPE=\"hidden\" NAME=\"EmpNum\"
VALUE=\"$EmpNum>$Fname $Lname\">\n");
print ("<INPUT TYPE=\"hidden\" NAME=\"PeriodID\"
VALUE=\"{$HTTP_POST_VARS['PeriodID']}\">\n");
echo "<tr>";
echo "<td><input type='submit' value='View Report'>";
echo "</td>";

Any help would be greatly appreciated.
Link to comment
Share on other sites

$_sessions

example.

session_start()

$varablename=($_session["name"]);


on the other page.

session_start()
echo $varablename;

Hope this helps


or from directly the database
[code]

$db=mysql_connect("localhost","name",password");
mysql_select_db("database",$db);
$query="select * from fieldname";
$result=mysql_query($query);
while($record=mysql_fetch_assoc($result)) {
while(list($title,$data)=each($record)) {

echo"<br>'".$title."' : '".$data."'<br>";
}
echo"<br>";
}
[/code]
Link to comment
Share on other sites

readarrow, I think this isn't what he wants.

Why did you add this:
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]print ("<INPUT TYPE=\"hidden\" NAME=\"EmpNum\"
VALUE=\"$EmpNum>$Fname $Lname\">\n");[/quote]
??

This will overwrite the selected value with the last value retrieved by the query.
Try to just remove it.

Also, remeber that the select dropdown MUST be in the <form>
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.