我希望能够将这段代码添加到一个包围回声的#34;"
并且stil能够输出下面当前的变量。这是我的思绪严重关闭的地方。
<td><?php echo $row_Recordset1['leaveID']; ?> </td>
<td><a href='Leavedetail.php?recordID=<?php echo $row_Recordset1['leaveID']; ?>'> <?php echo $row_Recordset1['serviceNumber']; ?> </a></td>
<td><?php echo $row_Recordset1['rank']; ?> </td>
<td><?php echo $row_Recordset1['organisation']; ?> </td>
<td><?php echo $row_Recordset1['lastName']; ?> </td>
<td><?php echo $row_Recordset1['firstName']; ?> </td>
<td><a class='btn btn-default' href='userDeleteProcess.php?id={$row_Recordset1['leaveID']}'>Delete</a></td>
答案 0 :(得分:5)
您需要使用ob_get_contents();
您的代码将如下所示。
<?php
ob_start();
?>
<td><?php echo $row_Recordset1['leaveID']; ?> </td>
<td><a href='Leavedetail.php?recordID=<?php echo $row_Recordset1['leaveID']; ?>'> <?php echo $row_Recordset1['serviceNumber']; ?> </a></td>
<td><?php echo $row_Recordset1['rank']; ?> </td>
<td><?php echo $row_Recordset1['organisation']; ?> </td>
<td><?php echo $row_Recordset1['lastName']; ?> </td>
<td><?php echo $row_Recordset1['firstName']; ?> </td>
<td><a class='btn btn-default' href='userDeleteProcess.php?id={$row_Recordset1['leaveID']}'>Delete</a></td>
<?php
$output = ob_get_contents();
ob_end_clean();
echo $output;
?>
答案 1 :(得分:0)
在cases如果您无法使用output buffering
作为 @PratikSoni 建议,我建议您查找printf()
或sprintf()
个函数以进行格式化输出
用法示例:
$output .= sprintf("<td>%s </td>", $row_Recordset1['leaveID']);
这样你就可以在一个变量中使用它,可以echo
或者你可能需要的其他任何东西。
答案 2 :(得分:-1)
看看是否有效
<td><?php echo $row_Recordset1['leaveID']; ?> </td>
<td><a href='Leavedetail.php?recordID=<?php echo $row_Recordset1['leaveID']; ?>'> <?php echo $row_Recordset1['serviceNumber']; ?> </a></td>
<td><?php echo $row_Recordset1['rank']; ?> </td>
<td><?php echo $row_Recordset1['organisation']; ?> </td>
<td><?php echo $row_Recordset1['lastName']; ?> </td>
<td><?php echo $row_Recordset1['firstName']; ?> </td>
<td><a class='btn btn-default' href='userDeleteProcess.php?id={$row_Recordset1['leaveID']}'>Delete</a></td>