1 回答
TA贡献1816条经验 获得超6个赞
不是启动和停止 PHP 代码,而是简单地回显要包含的 HTML 代码吗?它可能会帮助您组织您想要在循环中重复的内容以及您不想重复的内容。这是一个例子:
$myArray = []; //array that will hold the values you get from database for later use
$sql_client = "SELECT * FROM clienti WHERE nume = ? LIMIT 1";
$stmt_client = $conn->prepare($sql_client);
$stmt_client->bind_param("s", $nume);
$stmt_client->execute();
$result_client = $stmt_client->get_result();
echo '<table>'; //does not repeat
while($row = $result_client->fetch_row())
{
array_push($myArray, $row); //add each row to an array outside the scope of your loop
echo '<tr>'; //repeats once for each table row
foreach($row as $columnValue){
echo '<td><p>'.$columnValue.'</p></td>'; //repeats for every value in table
}
echo '</tr>';
}
echo '</table>'; //does not repeat
echo $myArray[0][0]; //echo first value of first row
- 1 回答
- 0 关注
- 111 浏览
添加回答
举报