Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在PHP中插入变量并在href中传递ID_Php_Codeigniter - Fatal编程技术网

如何在PHP中插入变量并在href中传递ID

如何在PHP中插入变量并在href中传递ID,php,codeigniter,Php,Codeigniter,我有代码在下面的href中传递ID: <a href="<?php echo base_url(); ?>app_summary/hoplist/<?php echo $row['id']; ?>" class="large-box"> 如何在href中将上述变量插入我的PHP传递ID 感谢您的建议……我不确定您打算在哪里包含这些变量,但我会这样做,当然会根据您的情况进行调整 <?php echo '<a href="' . base_url()

我有代码在下面的href中传递ID:

<a href="<?php echo base_url(); ?>app_summary/hoplist/<?php echo $row['id']; ?>" class="large-box">
如何在href中将上述变量插入我的PHP传递ID


感谢您的建议……

我不确定您打算在哪里包含这些变量,但我会这样做,当然会根据您的情况进行调整

<?php echo '<a href="' . base_url() . 'app_summary/hoplist/' . $row['id'] . $code . $matrix . date("m/d/Y") . 'class="large-box">'; ?>
$first='2018/01/20';
$end='2018/01/25';
$first=日期(“Y-m-d”,标准时间($first));
$end=日期(“Y-m-d”,标准时间($end));
试试这个

<a href="<?=base_url('app_summary/hoplist/'.$row['id'] .'/code='. urlencode($code). '/matrix='.urlencode($matrix));?>" class="large-box">

也许你可以试试这个:

<a href="<?php echo base_url('app_summary/hoplist/'.$row['id'].'/'.$first.'/'.$end);?>" class="large-box">

什么意思?你能再解释清楚吗?我真的不知道你的意思。如果你发布了你期望的输出/结果,你会怎么做?你能提供一个你期望在传递值时看到的示例url结构吗?@plonknimbuzz我使用link href显示我从行中选择的数据详细信息,所以我使用passing href id显示详细信息(与show edit form的条件相同)来指定我要处理的数据。但在我的详细视图中,我想使用
$first
$end
在详细视图中提供日期信息…@plonknimbuzz mungkin maksudnya di link berikutnya dia pingin bawa variable tambahan,cuma gimana caranya,mungkin ada alternatif solusi。。L1:也许她的意思是,在下一个视图(细节)中,她需要使用日期,但她不知道如何声明,也许你有其他解决方案……对不起,我更改了变量,如果我的变量是日期,该怎么办?上面的代码也是同样的方法吗?如果你喜欢,当然可以。任何变量都要确保它们遵循相同的格式。
<a href="<?=base_url('app_summary/hoplist/'.$row['id'] .'/code='. urlencode($code). '/matrix='.urlencode($matrix));?>" class="large-box">
<?php
$data = array(
    'code' => '2018/01/20',
    'matrix' => $matrix,
    'other' => 'some text with space'
);

?>

<a href="<?=base_url('app_summary/hoplist/'.$row['id'] .'/'. http_build_query($data));?>" class="large-box">
<a href="<?php echo base_url('app_summary/hoplist/'.$row['id'].'/'.$first.'/'.$end);?>" class="large-box">
  $id = $this->uri->segment(3);
  $frsdate = $this->uri->segment(4);
  $enddate = $this->uri->segment(5);