如何在此代码中设置显示类似&#34的条件;目前没有发布任何内容。请稍后再回来查看。"如果没有检索或输入?目前,如果没有检索或输入任何内容,它只会在前端显示任何内容。所以我想把一条消息代替一无所有。
if($seasontype=="pending"){
$result = " SELECT * FROM ".$wpdb->prefix."bidsys_picklist WHERE sport = ".$sport." AND pick_result='PENDING' ORDER BY game_date DESC";
$newmeta = $wpdb->get_results($result);
$resultvals = "";
foreach($newmeta as $data){
$game_details="";
$hometeam = "";
$visitorteam = "";
if(trim($data->game_details)!="")
$game_details = $data->game_details;
if($data->visitorteam!=""){ $visitorteam = "<br /><strong>Visitor Team:  </strong>".$data->visitorteam.""; }
if($data->hometeam!=""){ $hometeam = "<br /><strong>Home Team:  </strong>".$data->hometeam.""; }
$gamedate = strtotime($data->game_date);
$gametime = $data->game_time;
$endtime = strtotime('+30 minute',$gametime);
$nowtime = date('Y-m-d h:i:s');
$resultvals = $resultvals."<table class='inner_result'>
<tr class='hdr_3'>
<td colspan='4' >".date("n-d-Y",$gamedate)."<br />
".$gametime."
".$hometeam."
".$visitorteam."
<br /><div class='todays_pick' ><span><strong>Pick:</strong></span>  ".$data->your_pick."<br /><span><strong>Odds:</strong></span>  ".$data->pick_odds." </div>
<br /> ".$game_details."</td>
<td><br />Recommended Unit Play (Risk)<br />
<div class='todays_units' >".$data->units_play." Units</div>
</td>
</tr>
<tr>
</tr>
</table>";
}
echo $resultvals;
}
答案 0 :(得分:2)
if (empty($resultvals)) {
echo 'There are no results';
}
答案 1 :(得分:0)
获取返回的行数并检查行是否大于0
if($wpdb->num_rows>0){
echo "Your all posts";
}else{
echo "Nothing posted";
}