这是我的代码,每个剂量显示除了最后一个之外的所有数据库值;
<?php
foreach($result as $query2)
echo '<tr>';
echo "<td>" . $query2['firstname']. "</td>";
echo"<td>".$query2['username']."</td>";
echo"<td>".$query2['firstname']."</td>";
echo"<td>".$query2['lastname']."</td>";
echo"<td>".$query2['gender']."</td>";
echo"<td>".$query2['email']."</td>";
echo"<td>".$query2['mobile']."</td>";
echo"<td>".$query2['address']."</td>";
echo "<td><a href='http://localhost/service/change.php?edit_id=".$query2['uid']."'>Edit</a></td>";
//echo"<td><a href="http://localhost/service/change.php?edit_id= ".$query2['uid']."">Edit</a>
//<a href="http://localhost/service/delete.php?delet_id=<?php echo $query2['uid']?X</a></td>
echo "<td><a href='http://localhost/service/delete.php?delet_id=".$query2['uid']."'>x</a></td>";
echo '</tr>';
?>
答案 0 :(得分:0)
使用键值参考....
foreach($result as $key=>$value)
{
echo "<td>" . $value['firstname']. "</td>";
echo "<td>" . $value['lastname']. "</td>";
}