<form name="selectionForm" method="POST" action='query.php'>

echo "<select name='$q2['type']'>";
       //echo "<select name='selecttype'>";
       echo "<option value='Regular Project'>Regular Project</option>";
       echo "<option value='FSA Project'>FSA Project</option>";
       echo "</select></td>";
       echo "<input type='hidden' name='mid' value='$q2[0]'>";
       echo "<td width='140'><textarea rows='2' name='comments[]' cols='20' ></textarea></td>\n";
       echo "</tr>\n";



$selecttype = $_POST['selecttype'];

instead of calling 'selecttype' i want to call '$q2['type']'. how to get this value as dynamic.

3 Years
Discussion Span
Last Post by diafol

The hidden field should work:

echo "<input type='hidden' name='selectname' value='{$q2['type']}'>";

Retrieve by:


That should be equivalent to $_POST[$q2['type']]

However, that's pretty messy. You could search for POST keys with known values, but thinking about it, that may be even messier.

Edited by diafol


Thanks, hidden field should work, but inbetween like this.. i tried and outside of select tag the values are displaying..

echo "<select name='selecttype'>";

       echo "<input type='hidden' name='selecttype' value='{$q2[0]}'>";

       echo "<option value='Regular Project' >Regular Project</option>";
       echo "<option value='FSA Project'>FSA Project</option>";
       echo "<option value='TGF Project'>TGF Project</option>";
       echo "</select></td>";

Sorry don't understand. What's that got to do with the solution I proposed? You wanted to know how to pass a dynamic value for the select field and I showed you how it could be done. Now you've gone and changed the code from the commented out example in the original post to your last post.

I believe the solution was successful in giving $q2['type']? Please clarify what you mean. Did I waste my time proposing a solution to your original question? Did I misunderstand?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.