【问题标题】:pass arguments into anchor after sql querysql查询后将参数传递给锚
【发布时间】:2013-06-16 17:01:04
【问题描述】:

我该如何执行这个操作?

    this->datatables->select('first_name','roll_num')
    -> from('students')
    -> add_column('cancel',anchor("cancel/<first_name>/<roll_num>", 'Delete', array('onClick' =>"return confirm('Are you sure you want to delete?')")));

我需要为此传递first_nameroll_num。如何将这些参数传递给锚。

感谢您的帮助!

实际上我可以使用 ->add_column('cancel','Delete,','first_num',roll_num');

但是因为我想要一个是/否构造,所以我想要上面的语法....有没有其他方法可以添加是/否构造到它

【问题讨论】:

    标签: php sql codeigniter anchor database-table


    【解决方案1】:

    我认为这是不可能的。您必须首先检索结果(作为关联数组),然后在结果上调用 Codeigniter 的 anchor 函数。你的 RDBMS 完全不知道锚函数。

    可能看起来像这样的东西:

    $query = $this->datatables->select('first_name','roll_num')
    ->from('students')
    ->get();
    
    $results = $query->result();
    
    anchor("cancel/{$results[0]->first_name}/{$results[0]->roll_num}", 'Delete', array('onClick' =>"return confirm('Are you sure you want to delete?')"));
    

    我没有尝试上面的代码,所以它可能有一些合成器修复,但我认为一般的解决方案就在那里。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-08-02
      • 2015-04-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-10
      相关资源
      最近更新 更多