php combo box code nt working – PHP

  php

Q(Question):

my code is not working………

[PHP]<?php

echo"<select name=$sarea >";
$option = "<option value=\"Please select a Subject Area\">Please select a Subject Area</option> \n";
for ($i = 0; $i < count($subjarea); $i++) {
$option .= "<option ";
$option .= "value=\"$subjarea[$i]\">$subjarea[$i]</option> \n";
}
echo $option;
?>

</select>

<a href="webmain.php?sarea=<?php echo $sarea; ?>">show</a>;
<br>[/PHP]
webmain.php
[PHP]$sarea=$_GET[‘sarea’];
echo $sarea;[/PHP]

i want to print selected subject area on webmain.php

A(Answer):

first, you’re missing quotation marks in line 3
second, what is $sarea? I can see it nowhere defined. If you don’t get any output check the variable content with var_dump().

regards

A(Answer):

combo box is showing data but selected data doesnot go to other page
$sarea is the name given to combo box

A(Answer):

[PHP]my code is not working………[/PHP]
[PHP]<?php

echo"<select name=$sarea >";
$option = "<option value=\"Please select a Subject Area\">Please select a Subject Area</option> \n";
for ($i = 0; $i < count($subjarea); $i++) {
$option .= "<option ";
$option .= "value=\"$subjarea[$i]\">$subjarea[$i]</option> \n";
}
echo $option;
?>

</select>

<a href="webmain.php?sarea=<?php echo $sarea; ?>">show</a>;
<br> [/PHP]

webmain.php
[PHP]$sarea=$_GET[‘sarea’];
echo $sarea; [/PHP]

cobbo box has data.combo box is working but
i want to print selected subject area on webmain.php
which is not working
i think there is error in combo box name but i am not sure what should be there plz help

A(Answer):

combo box is showing data but selected data doesnot go to other page

unless you post the data (via submit) your selected data will go nowhere. once your script has finished delivering the html page you can’t do anything with php (including capturing user actions (like select something)) up to the next page load. so without a form you’ll just pass the name, not more, not less.

regards

A(Answer):

please do not double post! see posting guidelines

A(Answer):

kkshansid, you have been warned a few times previously about your lack of following posting guidelines. It is in your best interest to follow them as you are teetering towards receiving a temporary ban.

Posting Guidelines – read them.

LEAVE A COMMENT