Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
JSON でデータを返す次の mysql クエリがあります。0 レコードがあるかどうかを確認し、その事実を返す最良の方法は何ですか?
$row_num = mysql_num_rows($rslt); $data = array(); while ( $row = mysql_fetch_row($result) ) { $data[] = $row; } echo json_encode( $data );
$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 ); }