PHP foreach循环显示数据但没有重复值

时间:2017-02-26 21:44:41

标签: php arrays loops

我需要使用foreach循环显示数据,但前10个值中没有重复值,然后在后10个值中没有重复值并继续该过程。请帮我逻辑和代码。这是代码:

    global $wpdb;
    $results = $wpdb->get_results("SELECT * FROM wp_custom_form ORDER BY ID desc;");
    //print_r($results);

    echo "<br><br>";
    echo "<table class='table table-striped'>";
    echo "<th>Name</th>";
    // echo "<th>Email</th>";
    echo "<th>Website</th>";
    echo "<th>City</th>";
    echo "<th>Comment</th>";

    foreach($results as $result){

    echo "<tr>";
    echo "<td>".$result->Name."</td>";
    // echo "<td>".$result->Email."</td>";
    echo "<td><a target='blank' href='http://$result->Website'>".$result->Website."</a></td>";
    echo "<td>".$result->City."</td>";
    echo "<td>".$result->Comment."</td>";
    echo "</tr>";
    }
    echo "</table>";

0 个答案:

没有答案