<select name="parentgroup" type="text" id="select2" onchange="this.form.submit();">
<?php
echo "<option value=\"0\">All Users</option>";
$result = mysql_query("select * from login WHERE stato=1");
while ($myresults = mysql_fetch_array($result))
{
$username = $myresults['user_name'];
echo "<option value=\"".$username."\" ";
echo $username== $parentgroupid ? " selected" : "";
echo ">".$username."</option>";
}
?>
</select>
嗨...我应该使用<select>
中的第一个元素<option value=\"0\">All Users</option>
来从mysql数据库中获取值。
我现在想要如何将其分配给变量,并像$parentgroupid
答案 0 :(得分:1)
当您提交表单时(可能因为您从JavaScript引用它而存在):从表单的$_GET['name_of_form_control']
属性引用的文档中获取action
中的值。
答案 1 :(得分:1)
提交表单时,根据表单中指定的method
(“GET”或“POST”),该值将位于$_GET
或$_POST
数组中在您要提交的页面上。您可以按名称(控件的名称)检索值:
$parentgroupid = $_GET['parentgroup'];
或
$parentgroupid = $_POST['parentgroup'];