0
我从我的控制器传回的数据中生成这个表,我遇到的问题是通常返回的第一条记录[在这种情况下是Sephen C. Cox],“添加员工”按钮不是重定向我,而是其余的记录工作。有谁知道这个问题?PHP窗体输出
<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['Employee_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>
<form action="welcome.php" method="post"> <td><input type="submit" value="Add employee" name="submit[<?php echo $result['Employee_ID'] ?>]" > </td></form>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</thead>
<tbody>
</fieldset>
您是否尝试了不同的浏览器?我猜这可能是由您的提交按钮名称属性造成的。我只需要将名称和值作为名称来切换。编辑;还要为非法值字符转义值。 – Daniel
你在''之外创建一个窗体很奇怪。另外,在设置表单时,最好通过隐藏的输入类型传递员工ID。 – Raptor
你能给我一个例子,我将如何通过然后在我的控制器中调用它? – Undermine2k