Php sql到html对齐
我对sql显示html有一个小问题,出于某种原因,它将从数据库输入的第一个条目显示在实际页面的第二个条目中,因此,例如,数据库中有两个用户,他们的id为1和id为2,用户1的id将显示在页面的用户2部分中,这是一个下图显示了该问题 完整代码Php sql到html对齐,php,html,Php,Html,我对sql显示html有一个小问题,出于某种原因,它将从数据库输入的第一个条目显示在实际页面的第二个条目中,因此,例如,数据库中有两个用户,他们的id为1和id为2,用户1的id将显示在页面的用户2部分中,这是一个下图显示了该问题 完整代码 <?php $servername = "localhost"; $username = "root"; $password = "toor"; $dbname = "a3wasteland"; $conn = new mysqli($server
<?php
$servername = "localhost";
$username = "root";
$password = "toor";
$dbname = "a3wasteland";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT UID, BattlEyeGUID, Name, BankMoney FROM PlayerInfo";
$result = $conn->query($sql);
?>
<div class='cWidgetContainer ipsHide' data-controller='core.front.widgets.area' data-role='widgetReceiver' data-orientation='horizontal' data-widgetArea='header'>
<ul class='ipsList_reset'>
</ul>
</div>
<div id="elCmsPageWrap" data-pageid="2">
<div>
<div class='ipsGrid ipsGrid_collapsePhone'>
<div class='ipsGrid_span6'>
<div class='cWidgetContainer ipsHide' data-controller='core.front.widgets.area' data-role='widgetReceiver' data-orientation='horizontal' data-widgetArea='col1'>
<ul class='ipsList_reset'>
</ul>
</div>
</div>
<div class='ipsGrid_span6'>
<div class='cWidgetContainer ipsHide' data-controller='core.front.widgets.area' data-role='widgetReceiver' data-orientation='horizontal' data-widgetArea='col2'>
<ul class='ipsList_reset'>
</ul>
</div>
</div>
</div>
</div>
</div>
<div class='cWidgetContainer ' data-controller='core.front.widgets.area' data-role='widgetReceiver' data-orientation='horizontal' data-widgetArea='footer'>
<ul class='ipsList_reset'>
<li class='ipsWidget ipsWidget_horizontal ipsBox' data-blockID='plugin_20_sodPhpWidget_paxe9xcu5' data-blockConfig="true" data-blockTitle="PHP Code" data-controller='core.front.widgets.block'>
<div class='ipsWidget_inner '>
<p class='ipsType_reset ipsType_medium ipsType_light'>
<style>
.specialType_center th {
text-align: center;
}
</style>
</style>
<h2 class="ipsType_sectionTitle ipsType_reset cForumTitle ipsResponsive_hideTablet ipsResponsive_hidePhone <center> ">Arma 3 Player Stats</h2></center>
<table class="ipsTable ipsTable_responsive ipsTable_zebra ipsBox ipsType_center specialType_center ipsResponsive_hideTablet ipsResponsive_hidePhone">
<thead>
<tr>
<th>BattlEyeGUID</th>
<th>Name</th>
<th>BankMoney</th>
<th>UID</th>
</tr>
</thead>
<tbody>
<tr>
<?php
/* Other code */
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
?>
<td><span class="ipsType_negative"><?=$row["UID"]?></span></td></tr>
<td><span class="ipsType_negative"><?=$row["BattlEyeGUID"]?></span></td>
<td><span class="ipsType_negative"><?=$row["Name"]?></span></td>
<td><span class="ipsType_negative"><?=$row["BankMoney"]?></span></td>
<?php }
} else { ?>
<td colspan="5">0 results</td>
<?php } ?>
</tr>
</tbody>
</table>
</div></li>
</ul>
</div>
-
.specialType_中心th{
文本对齐:居中;
}
Arma 3玩家统计
巴特耶吉德
名称
银行存款
液体
0结果
试试这个:)
0结果
更新:
<table class="ipsTable ipsTable_responsive ipsTable_zebra ipsBox ipsType_center specialType_center ipsResponsive_hideTablet ipsResponsive_hidePhone">
<thead>
<tr>
<th>UID</th>
<th>BattlEyeGUID</th>
<th>Name</th>
<th>BankMoney</th>
</tr>
</thead>
<tbody>
<?php
/* Other code */
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
?>
<tr> <!-- tr -->
<td><span class="ipsType_negative"><?=$row["UID"]?></span></td></tr>
<td><span class="ipsType_negative"><?=$row["BattlEyeGUID"]?></span></td>
<td><span class="ipsType_negative"><?=$row["Name"]?></span></td>
<td><span class="ipsType_negative"><?=$row["BankMoney"]?></span></td>
</tr><!--/tr-->
<?php
}
} else {
?>
<td colspan="5">0 results</td>
<?php } ?>
</tbody>
</table>
液体
巴特耶吉德
名称
银行存款
0结果
好的,经过数小时的研究和测试,我发现了这个问题,而不是在第一个条目的末尾,我不得不把它放到最后一个条目,现在一切都正常了不,这也不起作用,谢谢你用任何方法打破了它,我想没有人能帮助解决这个奇怪的错误了吧?
<table class="ipsTable ipsTable_responsive ipsTable_zebra ipsBox ipsType_center specialType_center ipsResponsive_hideTablet ipsResponsive_hidePhone">
<thead>
<tr>
<th>UID</th>
<th>BattlEyeGUID</th>
<th>Name</th>
<th>BankMoney</th>
</tr>
</thead>
<tbody>
<?php
/* Other code */
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
?>
<tr> <!-- tr -->
<td><span class="ipsType_negative"><?=$row["UID"]?></span></td></tr>
<td><span class="ipsType_negative"><?=$row["BattlEyeGUID"]?></span></td>
<td><span class="ipsType_negative"><?=$row["Name"]?></span></td>
<td><span class="ipsType_negative"><?=$row["BankMoney"]?></span></td>
</tr><!--/tr-->
<?php
}
} else {
?>
<td colspan="5">0 results</td>
<?php } ?>
</tbody>
</table>