php中怎样获取下拉列表选项的值?
<?php$cn=mysql_connect('localhost',$DBUSER,$DBPASS);mysql_select_db($DBNAME,$cn);mysq...
<?php
$cn = mysql_connect('localhost', $DBUSER, $DBPASS);
mysql_select_db($DBNAME, $cn);
mysql_query("set names utf8;");
///提取章节信息
$sql1 = "select * from chapter order by id";
$result = mysql_query($sql1);
$forum_data1 = array();
while ($logged = mysql_fetch_array($result)) {
$forum_data1[] = $logged;
}
$num1=count($forum_data1);
for($i=0;$i<$num1;$i++)
{
$id=$forum_data1[$i]['id'];
}
mysql_free_result($result);
?>
<?php
if($_POST)
{
$starttime = $_POST['starttime'];
$endtime = $_POST['endtime'];
$cn=mysql_connect('localhost', $DBUSER, $DBPASS);
mysql_select_db($DBNAME, $cn);
mysql_query("set names utf8;");
$query2="update `chapter` set starttime='$starttime',endtime='$endtime';
mysql_query($query2);
mysql_close($cn);
}
?>
<form name="admin" action="" method="post">
<select id="chapter" style="width:140px" name="chapter" size="1">
<option selected="true">请选择章节</option>
<?php
$num = count($forum_data1);
for ($i = 0; $i < $num; $i++) {
?>
<option value="<? echo $forum_data1[$i]['id']; ?>">
<? echo $forum_data1[$i]['name']; ?></option>
<?
}
?>
</select>
<input id="update" class = "button" type = "submit" value="确定修改" >
</form>
这是我程序的一部分,如何获取我选中标题相对应的ID???请各位大侠帮忙看看。 展开
$cn = mysql_connect('localhost', $DBUSER, $DBPASS);
mysql_select_db($DBNAME, $cn);
mysql_query("set names utf8;");
///提取章节信息
$sql1 = "select * from chapter order by id";
$result = mysql_query($sql1);
$forum_data1 = array();
while ($logged = mysql_fetch_array($result)) {
$forum_data1[] = $logged;
}
$num1=count($forum_data1);
for($i=0;$i<$num1;$i++)
{
$id=$forum_data1[$i]['id'];
}
mysql_free_result($result);
?>
<?php
if($_POST)
{
$starttime = $_POST['starttime'];
$endtime = $_POST['endtime'];
$cn=mysql_connect('localhost', $DBUSER, $DBPASS);
mysql_select_db($DBNAME, $cn);
mysql_query("set names utf8;");
$query2="update `chapter` set starttime='$starttime',endtime='$endtime';
mysql_query($query2);
mysql_close($cn);
}
?>
<form name="admin" action="" method="post">
<select id="chapter" style="width:140px" name="chapter" size="1">
<option selected="true">请选择章节</option>
<?php
$num = count($forum_data1);
for ($i = 0; $i < $num; $i++) {
?>
<option value="<? echo $forum_data1[$i]['id']; ?>">
<? echo $forum_data1[$i]['name']; ?></option>
<?
}
?>
</select>
<input id="update" class = "button" type = "submit" value="确定修改" >
</form>
这是我程序的一部分,如何获取我选中标题相对应的ID???请各位大侠帮忙看看。 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询