0

我有以下 mysql 查询,它以 JSON 格式返回数据。检查是否有 0 条记录并返回该事实的最佳方法是什么?

$row_num = mysql_num_rows($rslt);
$data = array();
while ( $row = mysql_fetch_row($result) )
{
    $data[] = $row;     
}   
echo json_encode( $data );
4

1 回答 1

0
$row_num = mysql_num_rows($rslt);
$data = array();
while ( $row = mysql_fetch_row($result) )
{
    $data[] = $row;     
}   
if(!$data){
   echo "This is the government. We have removed your database!";
} else {
    echo json_encode( $data );
}
于 2012-06-04T19:21:27.387 回答