查询以显示数据库中的四个随机数据而不重复

uajslkp6  于 2021-06-19  发布在  Mysql
关注(0)|答案(1)|浏览(331)

我试图显示引号,但我似乎无法得到数据显示在索引页我仍然是新的php和mysql和它一直是一个拉夫路
html索引页

<div class="quote">
  <div class="container">

    <blockquote class="blockquote">
      <p class="mb-0">"<?php echo $row['feedback']; ?>"</p>
      <footer class="blockquote-footer"><?php echo $row['companyname']; ?></footer>
    </blockquote>

    <blockquote class="blockquote-reverse">
      <p class="mb-0">"<?php echo $row['feedback']; ?>"</p>
      <footer class="blockquote-footer"><?php echo $row['companyname']; ?></footer>
    </blockquote>

    <blockquote class="blockquote">
      <p class="mb-0">"<?php echo $row['feedback']; ?>"</p>
      <footer class="blockquote-footer"><?php echo $row['companyname']; ?></footer>
    </blockquote>

  </div>
</div>

和数据库连接

<?php
$hostname = "";
$username = "";
$password = "";
$db = "";

$dbconnect=mysqli_connect($hostname,$username,$password,$db);

if ($dbconnect->connect_error) {
  die("Database connection failed: " . $dbconnect->connect_error);
}
$query="SELECT companyname,feedback,status from review WHERE status=? ORDER BY RAND() LIMIT 3";
?>
vfh0ocws

vfh0ocws1#

<?php
    $hostname = "";
    $username = "";
    $password = "";
    $db = "";

    $dbconnect=mysqli_connect($hostname,$username,$password,$db);

    if ($dbconnect->connect_error) {
      die("Database connection failed: " . $dbconnect->connect_error);
    }
    $query=mysqli_query($dbconnect,"SELECT companyname,feedback,status from review WHERE status=? ORDER BY RAND() LIMIT 3");

$row = mysqli_fetch_assoc($query);
    ?>

相关问题