Jump to content

Archived

This topic is now archived and is closed to further replies.

JDPerry

Option Select

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.

Share this post


Link to post
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]

Share this post


Link to post
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>

Share this post


Link to post
Share on other sites

×

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.