dro62273 2012-02-08 14:20
浏览 55
已采纳

匹配输出的Html按钮和输出的Php / MySQL数据

public function dcr() {
    $query = $this->db->query("SELECT * FROM church_repo");
    foreach ($query->result() as $row) {
        $data = array('churchName'           => $row->church_name,
                      'streetAddress'       => $row->street_address,
                      'locationalState'     => $row->locational_state,
                      'locationalZIP'       => $row->locational_zip,
                      'locationalCountry'   => $row->locational_country,
                      'locationalCity'      => $row->locational_city,
                      'overseerAccountId'   => $row->overseer_account_id,
                      'taxExemptionNumber'  => $row->tax_exemption_number,
                      'accountStatus'       => $row->status,
                      );
        $this->load->view('admin-request', $data);
    }
}

In my Html I am outputting the above Php. Also in my Html, I have two buttons that have id's of 'pass' and 'fail'. What the script is doing when I have multiple rows is output those two buttons with the same id's on each outputted row. That's good, because it is doing what it needs to be doing, but now I'm not able to identify the outputted rows. So I need to be able to match each button set with the outputted Php. Any ideas?

  • 写回答

1条回答 默认 最新

  • douzhaochan6468 2012-02-08 14:32
    关注

    The way i typically do what you are attempting is by creating new forms for each row. and including a hidden input field in each row with the id.

    <input type="hidden" name="row_id" value="<?= $overseerAccountId;?>"/>

    when the user clicks pass/fail you simply use CI/PHP to get that value

    <?php 
     echo $this->input->post('row_id'); 
     //do work son.
    ?>
    

    the only difference between your code and what i typically do, is i move my foreach into the view and iterate through each row creating new <tr><td> instead of creating new tables like you are doing. But this could be considered against the MVC standard

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100