我需要帮助尝试$results
分开$row['citizenship']
。
- 我不知道如何遍历结果。
- 我对 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);