在表单操作上添加输入名称的url -segment

时间:2016-03-28 09:00:16

标签: php codeigniter codeigniter-3

我还在学习CodeIgniter,如何从值输入中添加<form action="getdata" method="GET"> <input name="id" type="text" value=""/> <input name="month" type="text" value=""/> <input name="submit" type="submit" value="Submit"/> </form>

name("id") = 001
name("month") = Feb

实施例

<form action="getdata/001/feb" method="GET">
    <input name="id" type="text" value=""/>
    <input name="month" type="text" value=""/>
    <input name="submit" type="submit" value="Submit"/>
</form>

结果

Calendar calendar = Calendar.getInstance();

3 个答案:

答案 0 :(得分:0)

您可以使用CI URI Class

从网址获取值

示例:

<form action="getdata/001/feb" method="GET">
    <input name="id" type="text" value="<?=$this->uri->segment(2)?>"/>
    <input name="month" type="text" value="<?=$this->uri->segment(3)?>"/>
    <input name="submit" type="submit" value="Submit"/>
</form>

<强>这里:

$this->uri->segment(2)将返回ID(001)和
$this->uri->segment(3)将返回姓名(二月)

答案 1 :(得分:0)

 <?php $ci =& get_instance(); ?>
<form action="getdata/001/feb" method="GET">
 <input name="id" type="text" value="<?=$ci->uri->segment(2)?>"/>
 <input name="month" type="text" value="<?=$ci->uri->segment(3)?>"/>
 <input name="submit" type="submit" value="Submit"/>
</form>

get_instance() in Codeigniter: Why assign it to a variable?

答案 2 :(得分:0)

你是否喜欢

之类的东西
if (id == 001 && month == Feb) {
 do something;
} else {
do whatever?;
}