gpt4 book ai didi

php - 打印超过 1 个用户

转载 作者:行者123 更新时间:2023-12-01 00:45:08 26 4
gpt4 key购买 nike

因此,当我使用我的代码时,它会从我的数据库中打印超过 1 个用户。

我只想打印一个用户,我尝试了我所知道的关于获取对象的一切。

谁能帮帮我?

$result = $mysqli->query("SELECT * FROM cms_users ORDER BY id ASC LIMIT 100");
while($row = $result->fetch_object()) {
echo '
<aside id="right">
<div id="main_sep"></div>
<div id="content_ajax"><article>
<h1 class="top">User panel</h1>
<section class="body">
<section id="ucp_top">
<a href="http://causticwow.net/home2/ucp/avatar" id="ucp_avatar">
<div>Change avatar</div>
</a>

<section id="ucp_info">

<aside>

<table width="100%">
<tbody><tr>
<td width="10%"><img src="images/icons/user.png"></td>
<td width="40%">Nickname</td>
<td width="50%">
<a href="http://causticwow.net/home2/ucp/settings" data-tip="Change nickname" style="float:right;margin-right:10px;"><img src="images/icons/pencil.png" align="absbottom"></a>
<a href="profile/1989" data-tip="View profile"> '.$row->Nickname.' </a>
</td>
</tr>
<tr>
<td width="10%"><img src="images/icons/world.png"></td>
<td width="40%">Location</td>
<td width="50%">
<a href="http://causticwow.net/home2/ucp/settings" data-tip="Change location" style="float:right;margin-right:10px;"><img src="images/icons/pencil.png" align="absbottom"></a>
'.$row->Location.'
</td>
</tr>
<tr>
<td width="10%"><img src="images/icons/plugin.png"></td>
<td width="40%">Expansion</td>
<td width="50%">
<a href="http://causticwow.net/home2/ucp/expansion" data-tip="Change expansion" style="float:right;margin-right:10px;"><img src="images/icons/cog.png" align="absbottom"></a>
'.$row->Expansion.'
</td>
</tr>
<tr>
<td width="10%"><img src="images/icons/award_star_bronze_1.png"></td>
<td width="40%">Account rank</td>
<td width="50%">'.$row->Rank.'
</td>
</tr>
</tbody></table>
</aside>

<aside>
<table width="100%">
<tbody><tr data-tip="Earn voting points by voting for the server">
<td width="10%"><img src="images/icons/lightning.png"></td>
<td width="40%">Voting points</td>
<td width="50%">'.$row->VP.'</td>
</tr>
<tr data-tip="Earn donation points by donating money to the server">
<td width="10%"><img src="images/icons/coins.png"></td>
<td width="40%">Donation points</td>
<td width="50%">'.$row->DP.'</td>
</tr>
<tr>
<td width="10%"><img src="images/icons/shield.png"></td>
<td width="40%">Account status</td>
<td width="50%">'.$row->AccStatus.'</td>
</tr>
<tr>
<td width="10%"><img src="images/icons/date.png"></td>
<td width="40%">Member since</td>
<td width="50%">'.$row->created.'</td>
</tr>
</tbody></table>
</aside>
</section>
<div class="clear"></div>
</section>

<div class="ucp_divider"></div>
<section id="ucp_buttons">
<a href="http://causticwow.net/home2/vote" style="background-image:url(images/vote_panel.jpg)"></a>

<a href="http://causticwow.net/home2/donate" style="background-image:url(images/donate_panel.jpg)"></a>

<a href="http://causticwow.net/home2/store" style="background-image:url(images/item_store.jpg)"></a>

<a href="http://causticwow.net/home2/ucp/settings" style="background-image:url(images/account_settings.jpg)"</a>
<a href="http://causticwow.net/home2/ucp/expansion" style="background-image:url(images/change_expansion.jpg)"></a>

<a href="http://causticwow.net/home2/teleport" style="background-image:url(images/teleport_hub.jpg)"></a>



<div class="clear"></div>
</section>

<div class="ucp_divider"></div>

</section>
</article></div>
</aside>
<div class="clear"></div>
</div>

<footer>
<a href="http://raxezdev.com/fusioncms" id="logo" target="_blank"></a>
<p>© Copyright 2014 Admin Frozty</p>
<p id="design"> <a target="_new" href=""></a></p>
</footer>
'; }

当它打印它们时,它首先在它应该在的地方打印一个,然后在页脚下打印另一个。

最佳答案

LIMIT 100 将返回最多 100 行。

因此,如果您更改为 LIMIT 1,您将只会得到一个结果。

此外,使用 while 将遍历所有结果。如果您确定只有一行,只需执行以下操作:

$row = $result->fetch_object();

关于php - 打印超过 1 个用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23267458/

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