我使用foreach loop
显示wp_share表中的一些数据。我正在尝试的是,如果没有数据,那么它会显示msg,如“找不到数据”,如果找到,则会转到循环。WordPress查询查询中的空数据
以下代码我写了,但它总是获取空值,但实际上有数据。
<?php
$me=$current_user->user_login;
$retrieve_data = $wpdb->get_results("SELECT * FROM wp_share where Status='onsell' and user!='$me'");
echo '<table border=0 class="table">
<tr> <th colspan="5" style="color:blue;border-bottom:2px solid blue;"> Purchase share from user offer</th> </tr>
<tr><th>OfferBy</th><th>OfferValue</th><th>Qnty</th> <th> ref</th> <th> action</th></tr>';
if (mysql_num_rows($retrieve_data)<=0) {
echo '<tr><td style="color:crimson;">' ."there is no data found". '</td>';
}
else{
foreach ($retrieve_data as $retrieved_data){
echo '<tr><td>'. $retrieved_data->user.'</td>';
echo '<td>'.$retrieved_data->offervalue.'</td>';
echo '<td>'. $retrieved_data->user.'</td>';
echo '<td>'. $retrieved_data->id.'</td>';
}
?>
您好我道歉,其实我想批准您的变化,但没有发现任何选项如何做到这一点thnks。 – Mithu
它已经完成了,你可以看到[修订历史记录](https://stackoverflow.com/posts/46314128/revisions)。拥有超过2,000个信誉点的社区成员会自动批准修改。 – halfer