gpt4 book ai didi

php - 按国家划分的表格

转载 作者:可可西里 更新时间:2023-11-01 08:20:00 26 4
gpt4 key购买 nike

<分区>

我需要帮助来尝试用 $row['citizenship'] 分隔 $results

  1. 我不知道如何遍历结果。
  2. 我对 PHP 的限制不止于此。

因此,我希望得到广泛的支持。

我希望能够做到这一点,但问题是我不知道如何通过循环将它分开:

---------------------------------------------------------------------
|citizen ID | Citizen Name | Citizenship| Date | User IP |
---------------------------------------------------------------------
| 123455 | Any Name | Albania |12/01/12 | 123.1234.123.121|
| 123455 | Any Name 2 | Albania |12/01/12 | 123.1234.123.121|
---------------------------------------------------------------------

---------------------------------------------------------------------
|citizen ID | Citizen Name | Citizenship| Date | User IP |
---------------------------------------------------------------------
| 123455 | Any Name 3 | Argentina |12/01/12 | 123.1234.123.121|
| 123455 | Any Name 4 | Argentina |12/01/12 | 123.1234.123.121|
---------------------------------------------------------------------

下面是我的 PHP 页面:

$con=mysqli_connect("localhost","citizens","password","citizens");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$color ="#ffffff";
$color3 ="#6CC";
$fontsize ="2";
$color3 ="#69C";

echo "<center><table border='3' cellspacing='0' cellpadding='2' class='sortable' bordercolor='#6699FF' width='100%'>
<tr>
<th >CitizenID</th>
<th>Citizen Name</th>
<th>Citizenship</th>
<th>Date Entry</th>
<th>IP of Admin</th>
</tr>";

$results = mysqli_query($con,"SELECT * FROM `data` ORDER BY citid ASC");
while($row = mysqli_fetch_array($results))
{

echo "<tr>";
echo "<td align='center' valign='middle' width='75px' bgcolor='" . $color3 . "'><font size='" . $fontsize . "'><a href='http://www.erepublik.com/en/citizen/profile/" . $row['citid'] . "' target='_blank'>".$row['citid']."</a></td>";
echo "<td align='left' valign='middle' bgcolor='" . $color . "'><font size='" . $fontsize . "'>" . $row['citname'] . "</td>";
echo "<td align='left' valign='middle' bgcolor='" . $color . "'><font size='" . $fontsize . "'>" . $row['citizenship'] . "</td>";
echo "<td align='left' valign='middle' bgcolor='" . $color . "'><font size='" . $fontsize . "'>" . $row['date'] . "</td>";
echo "<td align='left' valign='middle' bgcolor='" . $color . "'><font size='" . $fontsize . "'>" . $row['user_ip'] . "</td>";
echo "</tr>";
}
echo "</table>";
echo "<br>";

mysqli_close($con);

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com