显示数据库值?

时间:2017-02-03 18:53:14

标签: php html mysql

我是php/html的初学者,我需要你的帮助..

我只想发布<{p>的barangay

1- huyon huyon
2- talojongon 

当有相同的barangay时,它应该只显示为一个......不包括疾病。

请帮助我们将不胜感激:这是我目前的代码

barangay的状态 接受疾病

看下面的图片

 <div id="wrapper">
    <br><center><h3>TOP DISEASE IN THIS MONTH</h3></center>

        <br>
        <table id="keywords" class="table table-striped table-bordered">
            <thead>
                <tr>

                    <th><center>Barangay</th></center>
                    <th><center>Diseases</th></center>


                </tr>
            </thead>
            <tbody>
                <?php
                    include 'database.php';
                    $pdo = Database::connect();
                    $sql = 'SELECT * from patients WHERE receive="asd"';
                    foreach ($pdo->query($sql) as $row){
                        echo '<tr>';
                        echo '<td><center>'. $row['status'] . '</center></td>';
                        echo '<td><center>'. $row['receive'] . '</center></td>';

                    }
                    Database::disconnect();
                ?>
             </tbody>

  

    </div></div>



            <a class="btn btn-success" href="mail.php">Back</a>
                   <a class="btn btn-success" href="index.php">Home</a>
        </p></center>

There are the same barangay huyon huyon so the another must be delete

This is my current output..with the same

1 个答案:

答案 0 :(得分:2)

使用DISTINCT删除重复的行

将您的查询更改为

$sql = 'SELECT DISTINCT * FROM patients WHERE Diseases="asd"';