To check if the database has found any records in PHP, you'll need to perform a query on the database and then check if any rows were returned.
Here's an example:
main.php341 chars13 lines
In this example, we're using the mysqli_query
function to perform a SELECT statement on the my_table
table in the database. We then use the mysqli_num_rows
function to get the number of rows returned by the query.
If mysqli_num_rows
returns a number greater than 0, then the database found records that match the condition in the SELECT statement. We can return true
to indicate that the query was successful.
If mysqli_num_rows
returns 0, then no records were found that match the condition. We can return false
to indicate that the query was not successful.
gistlibby LogSnag