用于从不同表生成日期的MySql生成的php下拉菜单

时间:2012-02-08 17:18:06

标签: php mysql

我正在尝试从表格生成并由用户选择的下拉菜单中传递值。理想情况下,此值应转到下一页,用于从不同的表中选择数据。这就是我所拥有的。但我无法弄清楚如何通过“$ _POST [???]在另一端获取此值?感谢您的帮助。谢谢

    <?php require_once('Connections/results.php'); ?>
    <form action="results2.php" method="post">
    <?php 

        function dropdown($competitionid, $competitionname, $meets, $strOrderField, $strNameOrdinal, $strMethod="asc") {

       echo "<select name=\"$strNameOrdinal\">\n";
       echo "<option value=\"NULL\">Select one</option>\n";

       $strQuery = "SELECT * FROM meets ORDER BY date DESC";

       $rsrcResult = mysql_query($strQuery);

       while($arrayRow = mysql_fetch_assoc($rsrcResult)) {
          $strA = $arrayRow["competitionid"];
          $strB = $arrayRow["competitionname"];
          $strC = $arrayRow["date"];
          echo "<option value=\"$strA\">$strB $strC</option>\n";
       }

       echo "</select>";
    }

    ?>

    <p>Meets:<br />
    <?php dropdown(competition_id, location_name, location, location_name, location_name1); 

    ?>

     <p><input type="submit" /></p>
    </form>

2 个答案:

答案 0 :(得分:0)

<select name="dropdown">
<option value="$1">$1</option>
<option value="$2">$2</option>
<option value="$3">$3</option>
</select>

我不确定,但也许这只是试一试

$_POST['dropdown'];

答案 1 :(得分:0)

在您的示例中,post变量的名称将是$strNameOrdinal的值,该post变量的值将为$strA(或NULL)。