php怎么接收不到select标签下的option值
test 星期上午
第一节 课目 。 请选课目物理历史
时间 。 请选时间10:3011:00
第二节 课目 。 请选课目英语语文
时间 。 请选时间10:2011:30
第三节 课目 。 请选课目数学生物
时间 。 请选时间12:3013:00
第四节 课目 。 请选课目c++php
时间 。 请选时间14:3015:00
星期下午
第五节 课目 。 请选课目iospython
时间 。 请选时间15:4015:50
第六节 课目 。 请选课目cssjs
时间 。 请选时间16:3016:40
第七节 课目 。 请选课目javaruby
时间 。 请选时间17:3017:10
//request.php $_post, 'tuesday' => $_post, 'wednesday' => $_post, 'thursday' => $_post, 'friday' => $_post, 'saturday' => $_post, 'sunday' => $_post);// html是这样的
var_dump($_get);
// 这里接收不到值
// 但是url地址栏是有值的
// 因为在html里面我嵌套了php语法,但是不使用这个foreach就能接收到值哦?
// 我要的效果是这样的,但是接收不到值哦?
// 这是我最终想要的目的
$arr = array(
'monday' => $_post,'tuesday' => $_post,'wednesday' => $_post,'thursday' => $_post,'friday' => $_post,'saturday' => $_post,'sunday' => $_post
);
// html是这样的
回复内容: php怎么接收不到select标签下的option值
test 星期上午
第一节 课目 。 请选课目物理历史
时间 。 请选时间10:3011:00
第二节 课目 。 请选课目英语语文
时间 。 请选时间10:2011:30
第三节 课目 。 请选课目数学生物
时间 。 请选时间12:3013:00
第四节 课目 。 请选课目c++php
时间 。 请选时间14:3015:00
星期下午
第五节 课目 。 请选课目iospython
时间 。 请选时间15:4015:50
第六节 课目 。 请选课目cssjs
时间 。 请选时间16:3016:40
第七节 课目 。 请选课目javaruby
时间 。 请选时间17:3017:10
//request.php $_post, 'tuesday' => $_post, 'wednesday' => $_post, 'thursday' => $_post, 'friday' => $_post, 'saturday' => $_post, 'sunday' => $_post);// html是这样的
var_dump($_get);
// 这里接收不到值
// 但是url地址栏是有值的
// 因为在html里面我嵌套了php语法,但是不使用这个foreach就能接收到值哦?
// 我要的效果是这样的,但是接收不到值哦?
// 这是我最终想要的目的
$arr = array(
'monday' => $_post,'tuesday' => $_post,'wednesday' => $_post,'thursday' => $_post,'friday' => $_post,'saturday' => $_post,'sunday' => $_post
);
// html是这样的
select 不要写自闭合
谢邀。
遵循restful的话,传数据还是用post形式把
然后你需要获取的话,使用$_post['key']获取即可。
取不到值的话,建议你先使用js控制台查看你的key是否是正确的,避免重复。
你$_get为空,我没猜错的话,是key值重复了。为什么呢?
你看,foreach是遍历到最后了,你取到的肯定是空的了最后。
所以,结论是:
检查一下你的key值,避免重复。
这么明显的错误,当你用foreach的时候,html页面类似kemu1这样的 name一共有7个,当你提交的时候,后端 php 接收到的值其实会是 html页面中最后一个 name 选择框的值,所以目前后端接收的值只会是 星期7的。要改这个bug有两种方法,如下
把 select的name值都变成数组,如 kemu1 改成 kemu1[]
foreach循环的时候把$row的值也放到 select的name,如 {$row}-kemu1,这样没有重复的name值就ok