This might help
$iRows = db2_num_rows($stmt23);
if ($iRows > 0) {
//Do if zero results
} else {
//Do if more results
}
or you can check
if ($fin23) {
//Row was fetched
}
题
I am trying to condition a table so that it only shows when SQL results are returned. If no values are returned, then do not display the table. Here is what I have:
## PPAP Information
$q23 = "SELECT * FROM $modlible.P0353 JOIN $amflible.CUSMAS ON PCUSNO = CUSNO WHERE PITEM='$id'";
$stmt23 = db2_prepare($con, $q23);
$result23 = db2_execute($stmt23);
$fin23 = db2_fetch_assoc($stmt23);
How can I detect whether or not a result has been returned to me?
解决方案
This might help
$iRows = db2_num_rows($stmt23);
if ($iRows > 0) {
//Do if zero results
} else {
//Do if more results
}
or you can check
if ($fin23) {
//Row was fetched
}
其他提示
You can check the SQL code returned. If the code is SQL0100 (+100) it means no rows were returned.
If there are no results your while loop will not loop
while($fin23 = db2_fetch_assoc($stmt23)){
// print your results
}