1
我将尝试尽可能地解释这一点。我从控制器返回一组结果。我希望将选定行的主键发送到另一个控制器,当用户单击“添加员工”按钮时,该控制器将管理将记录插入到数据库中。我的主要关键是MOVIE_ID
。它目前正在返回两个像这样的MOVIE_ID
{12341, 31351}
的数组。我的问题是:将视图中的变量传递给控制器
如何将每个电影ID唯一地与相应的行按钮相关联?
我可以通过
action=""
属性将一个变量传递给控制器吗?我需要JS吗?
<fieldset id= "results">
<?php if (isset($results) And count($results)) : ?>
<table id="box-table-a" summary="Employee Sheet">
<thead>
<tr>
<th scope="col">Employee</th>
<th scope="col">Salary</th>
<th scope="col">Bonus</th>
<th scope="col">Supervisor</th>
<th scope="col">Action</th>
</tr>
<?php foreach ($results as $result) : ?>
<tr>
//Primary key <?php echo $result['MOVIE_ID!'];?>
<td><span class="Employee_name"><?php echo $result['Employee']; ?> </span></td>
<td><span class="Salary"><?php echo $result['Salary']; ?> </span> </td>
<td><span class="Bonus"><?php echo $result['Bonus']; ?> </span> </td>
<td><span class="Supervisor_name"><?php echo $result['Supervisor']; ?> </span></td>
<td><input type="submit" value="add employee" > </td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</thead>
<tbody>
</fieldset>
的问题是,这些数据可以更改,所以我真的不能硬编码在每一个ID为它只是需要抓住它的电影按照它从控制器返回的顺序。所以我想发送第1行,如“Movie_ID [1]”或其他...如果你跟着我? – Undermine2k
@ Undermine2k的权利,所以你写'... name =“submit [<?php echo $ result ['MOVIE_ID!']?>]”...' –
谢谢,我会试试看。 – Undermine2k