我必须从select标签中选择数据,而不是选择value作为默认选择值
<select name="time" >
<option selected="selected" >timings</option>
<option value="155">9:00AM - 12:00PM</option>
<option value="244">12:00AM - 15:00PM</option>
</select>
我想选择12:00 AM - 15:00 PM值并将其存储在我的数据库中。怎么做任何想法。
提前致谢
Ameeth
答案 0 :(得分:3)
<select name="time">
<option selected="selected" >timings</option>
<option value="9:00AM - 12:00PM">9:00AM - 12:00PM</option>
<option value="12:00AM - 15:00PM">12:00AM - 15:00PM</option>
</select>
<?php
$value = $_POST["time"]; //what method you are using
?>
或
<select name="time" >
<option selected="selected" >timings</option>
<option value="155">9:00AM - 12:00PM</option>
<option value="244">12:00AM - 15:00PM</option>
</select>
<?php
$value = "";
switch($_POST['time']){
case '155':
$value="9:00AM - 12:00PM";
break;
case '244':
$value = "12:00AM - 15:00PM";
break;
default:
$value = "No data found";
break;
}
?>
答案 1 :(得分:1)
你有两个选择;
12:00AM - 15:00PM
参数中使用value=""
。OR
在PHP文件中执行类似的操作,以收集数据并将其插入db;
if ($_POST['time'] == "155")
{
$time = '9:00AM - 12:00PM';
}
elseif ($_POST['time'] == "244")
{
$time = '12:00AM - 15:00PM';
}
// do rest of the data insertion into db