1 回答

TA貢獻(xiàn)1777條經(jīng)驗(yàn) 獲得超3個(gè)贊
您可以region從查詢中獲取所有名稱,然后將其傳遞給您next query并打印record與該查詢相關(guān)的所有名稱,即:
<?php
$region = mysqli_query($conn,"SELECT DISTINCT region FROM country") or die($conn->error);
if($region->num_rows > 0)
{ {
while($row = $region->fetch_assoc())
{
//printing region name
echo "<p>" . $row['region'] . "</p>";
//only those row will be retrieve which belong to current region name
$result = mysqli_query($conn,"SELECT * FROM country WHERE region LIKE '$row['region']'") or die($conn->error);
//printing table
echo "This is table Build";
echo "<table border='1'>";
$i = 0;
while($row1 = $result->fetch_assoc())
{
if ($i == 0) {
$i++;
echo "<tr>";
foreach ($row1 as $key => $value) {
echo "<th>" . $key . "</th>";
}
echo "</tr>";
}
echo "<tr>";
foreach ($row1 as $value) {
echo "<td>" . $value . "</td>";
}
echo "</tr>";
}
echo "</table>";
}
}
mysqli_close($conn);
?>
- 1 回答
- 0 關(guān)注
- 138 瀏覽
添加回答
舉報(bào)