0

(SOLVED by trincot)

I am trying to save a selected item from a dropdown menu as a variable called $name. The list is populated from a mysql table, so the list is filled automatically with the contents of a table's column called "App". The list is filled correctly, however I am having trouble saving what is selected using my "Go" button. Here is the code I have at the moment.

<form method="post" action="">
<?php
echo '<div align="center">';
  echo '<p>Select Application  ';
  echo '<select name="AppChoose">';
  while($row= mysql_fetch_array ($result)) {
  echo '<option value="$row[\'App\']">' . $row['App'] . '</option>'; 
  }
 echo '</select>';
 echo '</div>';
?>

<input type="submit" value="Go!">

</form>

<!-- Once you hit submit -->
<?php 
if (isset($_POST['AppChoose'])){
$name = $_POST['AppChoose'];
echo $name;
}
?>

When Go! is pressed, the print of $name will only return "$row[App]" instead of the actual value of what was selected. I'm rather new at html and php, so any suggestions would be great. Thanks ahead of time!

I have already tried changing the $_POST save to double quotations to attempt to avoid the variable printing "as is" and that did not change the value of the variable at all.

Foster
  • 746
  • 2
  • 8
  • 14
  • Hey Marc B, I read through what was linked as a duplicate question and tried changing up the 'AppChoose to double quotes to try to avoid it printing "as is", however that doesn't seem to solve the problem. Could you unmark this as a duplicate or give any more details on how to solve this issue? Thanks. – Foster Jul 25 '16 at 19:40
  • 1
    You should do `echo '";` – trincot Jul 25 '16 at 20:32
  • Thank you! This works wonderfully! – Foster Jul 25 '16 at 20:37

0 Answers0