如何在按钮单击时将值从视图传递到控制器

时间:2015-05-28 06:53:16

标签: php ajax codeigniter

如何将值从视图传递到控制器onclick ...我需要将每一行保存到数据库中

<table border="1" cellpadding="4" cellspacing="0">
    <tr>
        <td>from</td>
        <td>to</td>
        <td>title</td>
        <td>openletter</td>
        <td>open_id</td>
    </tr>

    <?php foreach ($r->result() as $row): ?>

        <tr>
            <td><?php echo $row->from; ?></td>
            <td><?php echo $row->to; ?></td>
            <td><?php echo $row->title; ?></td>
            <td><?php echo $row->openletter; ?></td>
            <td><?php echo $row->open_id; ?></td>
            <td><input type="button" value="add to archieve" onclick="<?php echo $row->from; ?>" /></td>
            <td><input type="button" value="add to new" onclick="" /></td>
            <td><input type="button" value="Discard" onclick="" /></td>
        </tr>

    <?php endforeach; ?>
</table>

1 个答案:

答案 0 :(得分:2)

使用此

<td>
<input type="button" value="add to new" onclick="<?php echo base_url()?>index.php/controller/function" />
</td>
<td>
<input type="button" value="Discard" onclick="<?php echo base_url()?>index.php/controller/function" />
</td>