如何恢复我随机发布的用户,当我点击我的个人资料时,当我返回php时再次显示它们



您好,我在我的网站上随机发布了用户,但是当我单击用户以查看他的个人资料时,我希望当我返回时,我会依靠相同的用户。请帮助我

这是我为显示用户而键入的代码,现在我想重新发布我已经随机发布的所有用户

此查询将用于随机显示所有用户

$listsAllUsers = $db->prepare("SELECT users1.id, username, sex, country, years, city, 
regionOuProvince, titleOuSlogan, about, 
orientation, looking_for, civil_status, img_original FROM users1 
LEFT JOIN users2 ON users1.id = users2.user_id
LEFT JOIN pictures ON users1.id = pictures.user_id
WHERE pictures.active_profile = ?
ORDER BY RAND() $limit");
$listsAllUsers->execute(['2']);
$listAllUsers = $listsAllUsers->fetchAll(PDO::FETCH_OBJ);
<?php if ($data->display_user_fetch == '1'): ?>
<div class="container">
<ul class="usersFetch">
<center>
<?php if (count($listAllUsers) != 0): ?>
<?php foreach ($listAllUsers as $listAllUser): ?>
<li style="text-align:center;">
<div class="userFetchBloc">
<a href="<?= WEBSITE_NAME_URL ?>/profile/<?= strtolower($listAllUser->username) ?>">
<img src="/<?= $listAllUser->img_original ?>" class="img_user_fetch_bloc" style="width: 100%;" alt="Meeting <?= $listAllUser->username ?> On <?= WEBSITE_NAME ?>">
</a>
<div class="fetchInfosUserStandardProfile">
<span class="fetchInfosUserText">
&nbsp;<span class="infosUserText2"><?= $listAllUser->username ?>, </span><?= date('Y') - $listAllUser->years ?> old&nbsp;<br>
&nbsp;<?= $listAllUser->city ?><span class="infosUserText">, <?= $listAllUser->regionOuProvince ?></span>&nbsp;
<span class="infosUserText2"><br>&nbsp;<?= NbrePictures($listAllUser->id) ?> photo<?= NbrePictures($listAllUser->id) > 1 ? 's' : ''; ?>&nbsp;</span>
</span>
</div>
</div>
<div class="all_necessary_infos">
<div>
<b><?= $listAllUser->titleOuSlogan ?></b>
</div>
<em><?= $listAllUser->civil_status ?> <?= $listAllUser->sex ?> of <?= date('Y') - $listAllUser->years ?> years looking for <?= verify_looking_for($listAllUser->id, $listAllUser->sex) ?> for <?= $listAllUser->orientation ?></em>
<div class="wideDiv">
<?= $listAllUser->about ?>
</div>
<strong>Meet</strong> <a style="color: #be0210;" href="<?= WEBSITE_NAME_URL ?>/meet-<?= lcfirst($listAllUser->sex) ?>-<?= suppr_accents($listAllUser->city) ?>" style="color:#be0210;"><?= $listAllUser->city ?></a>, 
<a style="color: #be0210;" href="<?= WEBSITE_NAME_URL ?>/meet-<?= lcfirst($listAllUser->sex) ?>-<?= suppr_accents($listAllUser->regionOuProvince) ?>" style="color:#be0210;"><?= $listAllUser->regionOuProvince ?></a>, 
<a style="color: #be0210;" href="<?= WEBSITE_NAME_URL ?>/meet-<?= lcfirst($listAllUser->sex) ?>-<?= lcfirst($listAllUser->country) ?>" style="color:#be0210;"><?= $listAllUser->country ?></a>
</div>
</li>
<?php endforeach ?>
<?php else: ?>
<p style="text-align: center;">No users on <?= WEBSITE_NAME ?></p>
<?php endif ?>
</center>
</ul>
<?php if (count($listAllUsers) != 0): ?>
<div id="pagination" style="position: relative; top: 10px; bottom: 5px;"><?= $pagination ?></div>
<?php endif ?>
</div>
<?php else: ?>
<?php if (count($listAllUsers) != 0): ?>
<?php foreach ($listAllUsers as $key => $listAllUser): ?>
<div id="user_container_testimony">
<div class="userTestimony">
<span class="img_message_testimony">
<a href="<?= WEBSITE_NAME_URL ?>/profile/<?= strtolower($listAllUser->username) ?>">
<img src="/<?= $listAllUser->img_original ?>" class="img_testimony" alt="This image shows <?= $listAllUser->username ?> meeting on <?= WEBSITE_NAME ?>.">
</a>
</span>
<div class="fetchInfosUserStandardProfileStyle">
<span class="fetchInfosUserText">
&nbsp;<span class="infosUserText2"><?= $listAllUser->username ?>, </span><?= date('Y') - $listAllUser->years ?> old&nbsp;<br>
&nbsp;<?= $listAllUser->city ?><span class="infosUserText">, <?= $listAllUser->regionOuProvince ?></span>&nbsp;
<span class="infosUserText2"><br>&nbsp;<?= NbrePictures($listAllUser->id) ?> photo<?= (NbrePictures($listAllUser->id) > 1) ? 's' : '' ?>&nbsp;</span>
</span>
</div>
<div class="allTestimony">
<div class="titleTestimony">
<strong><u><?= $listAllUser->titleOuSlogan ?></u></strong> 
</div>
<div class="subtitleTestimony">
<span class="describeSubtitleTestimony">
<u><a href="<?= WEBSITE_NAME_URL ?>/profile/<?= strtolower($listAllUser->username) ?>" style="color: #be0210;"><?= $listAllUser->username ?></a></u> <?= $listAllUser->civil_status ?> <?= $listAllUser->sex ?> of <?= date('Y') - $listAllUser->years ?> years looking for <?= verify_looking_for($listAllUser->id, $listAllUser->sex) ?> for <?= $listAllUser->orientation ?>
</span> 
</div>
<div class="testimony">
<span class="describeTestimony">
<?= mb_strlen($listAllUser->about) > 350 ? substr($listAllUser->about, 0, 350).' <a href="'.WEBSITE_NAME_URL.'/profile/'.strtolower($listAllUser->username).'" style="color: #be0210;">More Read...</a>' : $listAllUser->about ?>
</span>
</div>
</div>
<div class="meetCityRegion">
<strong>Meet</strong> <u style="color: #be0210;"><a href="<?= WEBSITE_NAME_URL ?>/meet-<?= lcfirst($listAllUser->sex) ?>-<?= suppr_accents($listAllUser->city) ?>" style="color:#be0210;"><?= $listAllUser->city ?></a></u>, 
<u style="color: #be0210;"><a href="<?= WEBSITE_NAME_URL ?>/meet-<?= lcfirst($listAllUser->sex) ?>-<?= suppr_accents($listAllUser->regionOuProvince) ?>" style="color:#be0210;"><?= $listAllUser->regionOuProvince ?></a></u>, 
<u style="color: #be0210;"><a href="<?= WEBSITE_NAME_URL ?>/meet-<?= lcfirst($listAllUser->sex) ?>-<?= lcfirst($listAllUser->country) ?>" style="color:#be0210;"><?= $listAllUser->country ?></a></u>
</div>
</div>
</div>
<?php endforeach ?>
<div id="pagination" style="position: relative; top: 10px; bottom: 5px;"><?= $pagination ?></div>
<?php else: ?>
<p style="text-align: center;">You have not traded anything with this user yet.</p>
<?php endif ?>
<?php endif ?>

我希望你帮我随机带走我已经发布的用户

目前,当您使用语句进行ORDER时,这里没有简单的方法来">锁定"RAND()相同的用户设置,因为这里RAND每次调用SQL查询时都会生成narnodm顺序( =在每个页面加载时(。

您可以使用 3 种方式:

  • 生成随机键以分隔表中的列并按其排序。这可以随机排序,随着时间的推移固定下来——它可以列出可重复的视图。
  • 选择当前用户的随机列表,并将该列表缓存在某个位置,稍后返回该页面时加载它。
  • 也许你汽车帮助allo浏览器缓存页面,其中包含在请求中发送正确HTTP标头的用户列表。

问题是为什么要随机排序?

最新更新