Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem referencing the results of drop down menu from a form

Status
Not open for further replies.

Delboy14

Programmer
Jun 21, 2001
213
GB
I am having a problem refering to the result of a drop down menu from a form. I have included the relevant code below
the first section of code is the drop down menu which is populated from a text file.

<code>
<select name=&quot;Forname_Drop&quot;>
<?php
for($rowCounter=0; $rowCounter < count($rows); $rowCounter++)
{
$cells = explode($second_break, $rows[$rowCounter]);
echo $rows[rowCounter];
?>
<option value=&quot;<?php echo $cells[0]; ?>&quot;><?php echo $cells[0];?></option>

<?php } ?>

</select></code>

Then I attempt to refer to the result of the drop down choice in the resulting page using this code; which attempts to extract the details of a person from a text file if there name equals the drop down result

<code>
<?php
for($rowCounter=0; $rowCounter < count($rows); $rowCounter++)
{
$cells = explode($second_break, $rows[$rowCounter]);
echo $rows[rowCounter];
if ($Forname_Drop = $cells[0]) {
?>
<tr><td>
Name: <?php echo $Forname_Drop; ?><br>
Project: <?php echo $cells[1]; ?> <br>
Cost Center: <?php echo $cells[2]; ?> <br>
Region: <?php echo $cells[3]; ?> <br>
</td>
</tr>
<?php }} ?>
</code>

My result is that the details for all people within the text file are displayed, whereas I only want the person whose name is selected in the drop down
 
Change
Code:
   if ($Forname_Drop = $cells[0]) {
to
Code:
   if ($Forname_Drop == $cells[0]) {
You are using the assignment operator, whereas you should be using the equal to operator. //Daniel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top