Copy link to clipboard
Copied
I tried a query in PHPmy admin for a single record, and it returned
Rows 0 - 0 1 total.
Did the same for a non existent record and it came up with Zero results (empty)
So it looks like you need to do some math to work out whow many rows there are, as it seems to return 0 when there is only one record and 0 when there are none.
How do you check mysql_inumrows($result) for zero rows returned?
Its possibly tied to the fact that record counts begin at 0.
H Walker
I don't use mysqli, but you should be able to do the following:
if (!mysqli_numrows($result) {
// no rows were returned
}
You are correct that PHPmyAdmin begins its row assignment numbers with zero, not 1, so if there are 25 rows, they are listed as rows 0 - 24, but mysqli_numrows is reporting the sum, so it should count from 1, not zero.
Bregent, I think he was just using PHPmyAdmin to test his query.
Copy link to clipboard
Copied
I'm not sure what you're asking and not sure what PHPMyAdmin has to do with anything. You're talking about using this in a php script, right? Can you please clarify and include an example of your code that is not working as expected.
>Its possibly tied to the fact that record counts begin at 0.
No. The function returns the number of rows in the result set.
Copy link to clipboard
Copied
Sorry Bregent, for being a bit unclear. I was using PHPmyadmin to test my query as I always do, especially on a delete query.
Rob Hecker realised that and gave me the correct answer.
My code (from memory as I am on a different computer today) was like the following:
if (mysql_inumrows($result) <>0 ) {
then // records returned
} else {
// no records returned
}
Thanks for the answer.
Howard
Copy link to clipboard
Copied
I don't use mysqli, but you should be able to do the following:
if (!mysqli_numrows($result) {
// no rows were returned
}
You are correct that PHPmyAdmin begins its row assignment numbers with zero, not 1, so if there are 25 rows, they are listed as rows 0 - 24, but mysqli_numrows is reporting the sum, so it should count from 1, not zero.
Bregent, I think he was just using PHPmyAdmin to test his query.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more