Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/251.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何恢复我在返回php时单击配置文件再次显示时随机发布的用户_Php - Fatal编程技术网

如何恢复我在返回php时单击配置文件再次显示时随机发布的用户

如何恢复我在返回php时单击配置文件再次显示时随机发布的用户,php,Php,您好,我在我的网站上随机发布了这些用户,但是当我点击一个用户查看他的个人资料时,我希望当我返回时,我会回到相同的用户。请帮帮我 这是我为显示用户而键入的代码,现在我想重新发布我已经随机发布的所有用户 //此查询将用于随机显示所有用户 $listsAllUsers = $db->prepare("SELECT users1.id, username, sex, country, years, city, regionOu

您好,我在我的网站上随机发布了这些用户,但是当我点击一个用户查看他的个人资料时,我希望当我返回时,我会回到相同的用户。请帮帮我

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

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

$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 ?>
$listsAllUsers=$db->prepare(“选择users1.id、用户名、性别、国家、年份、城市、,
RegionUpovince,titleOuSlogan,关于,
方向、查找、公民身份、img原始用户1
users1.id=users2.user\u id上的左连接users2
左连接users1.id=pictures.user\u id上的图片
其中pictures.active_profile=?
按兰特订购($limit”);
$listsAllUsers->execute(['2']);
$listAllUsers=$listsAllUsers->fetchAll(PDO::FETCH_OBJ);
  • ,旧的
    ,
    照片 寻找的岁月 见面, ,
  • 上没有用户

,旧的
,
照片 寻找的岁月 见面, ,

您尚未与该用户进行任何交易


我希望您能帮助我随机获取我已经发布的用户

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

您可以使用3种方式:

  • 生成随机键以分隔表中的列并按其排序。它可以包装随机订单,并在一定时间内将其固定–它可以生成可重复的列表视图
  • 选择当前用户的随机列表,并将该列表缓存到某个位置,稍后返回该页面时加载该列表
  • 也许你可以用具有发送权限的用户列表帮助所有浏览器缓存页面

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

对于我的网站数据,我想以随机模式显示用户,您会发现它更有趣。。。这里是我的网站,我正在工作,我真的不明白你告诉我的三种方式给我一个例子,我给你发送了网站链接正如我所说,你的要求并不简单。对于你们来说,最简单的方法是在浏览器中添加内容缓存头来响应缓存页面,大约5分钟。查看PHP中的vore HTTP缓存:和
header()
函数的更多信息:。