duanquan4451 2014-08-25 21:33
浏览 8
已采纳

使用锚标记从表控制器传递值

I am new to CI.. I want to pass an id from table using anchor tag... but I can't pass maybe my code is not correct.

View . . . . .

    <?php
    foreach ($records as $value) {
        echo "<tr>";
        echo "<td align=center >" . $value -> id . "</td>";
        echo "<td align=center >" . $value -> name . "</td>";
        echo "<td align=center >" . $value -> lastname . "</td>";
        echo "<td align=center >" . $value -> classlevel . "</td>";
        echo "<td align=center >" . $value -> mobileno . "</td>";
        echo "<td align=center >" . $value -> address . "</td>";
        echo "<td align=center >" . anchor('StudentController/del_record/'.$value->id ,'Delete') . "</td>";
        echo "</tr>";
    }
?>

Controller....

public function del_record($value) {
    $data = array('id' => $this -> input -> post('$value->id'));
    if ($data = $this -> Student_Model -> del_record($data)) {
        echo "The operation has been successfully completed";
    } else {
        echo "query not run";
    }
}

`

I am waiting for your response...

  • 写回答

1条回答 默认 最新

  • donglu6303 2014-08-26 00:46
    关注

    At the moment you are trying to pass the ID to delete via GET (in the URL). You can accessing this via $value inside your function declaration. As you are passing a single value (the ID) you don't need to need to access it as if it were and object.

    Change this:

    $data = array('id' => $this -> input -> post('$value->id'));
    

    to this:

     $data = array('id' => $this -> input -> post('$value'));
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比