2

When I load my page, the value of the variable, $v_UpdateONE, is "Select Version". When I select a version, the value goes blank. I need to grab the selected value for use in a DB update statement. Thank you for any assistance. -James

<FORM METHOD="post" ACTION="Update.php" WIDTH="50">
<?php

$avQuery = "SELECT $v_software1 FROM version_master.vermas_availableversions WHERE $v_software1 IS NOT NULL ORDER BY SortCol DESC";
  $a_AvailVers = mysql_query($avQuery);
  #_Version dropdown box
  echo "<select NAME='AvailVersONE' ONCHANGE=submit()>";
  echo "<option>Select Version</option>";
  while ($row = mysql_fetch_array($a_AvailVers)) {
    echo "<option value='" . $row['$v_software1'] . "'>" . $row[$v_software1] . "</option>";
  }
 echo "</select>";

 $v_UpdateONE = $_POST['AvailVersONE'];
 echo $v_UpdateONE;

?>
</FORM>
0

2 Answers 2

1

You have an error in

value='" . $row['$v_software1'] . "'

Since $v_software1 is in single quotes, it will be literal $v_software1.

Try removing the quotes -

value='" . $row[$v_software1] . "'
Sign up to request clarification or add additional context in comments.

Comments

0

You need to post before you can read $_POST data.

Form File

 <FORM METHOD="post" ACTION="Update.php" WIDTH="50">
<?php

$avQuery = "SELECT $v_software1 FROM version_master.vermas_availableversions WHERE $v_software1 IS NOT NULL ORDER BY SortCol DESC";
  $a_AvailVers = mysql_query($avQuery);
  #_Version dropdown box
  echo "<select NAME='AvailVersONE' id='AvailVersONE' ONCHANGE=submit()>";
  echo "<option>Select Version</option>";
  while ($row = mysql_fetch_array($a_AvailVers)) {
    echo "<option value='" . $row['$v_software1'] . "'>" . $row[$v_software1] . "</option>";
  }
 echo "</select>"; 
?>
<button type="submit"> <!-- this will draw a submit button -->
</FORM>

then on your Update.php

<?php

$v_UpdateONE = $_POST['AvailVersONE'];
echo $v_UpdateONE;

?>

Sometimes, the ID needs to be filled up (browser dependent)

1 Comment

Thank you. The response from Sean, above, worked great. But since you took the time to help I wanted to test your maneuver as well for feedback. With Sean's solution, your solution also worked and provided the added benefit of placing my post elsewhere if needed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.