Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the method for php mysql to judge whether there is data or not?

Shulou Source: shulou.com Published: 2022-06-02 23:02:24 09月10日 Update

This article mainly introduces "what is the method for php mysql to judge whether there is data or not". In daily operation, I believe that many people have doubts about the method of php mysql to judge whether there is data or not. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for everyone to answer the doubts of "what is the method of php mysql to judge whether there is data or not?" Next, please follow the editor to study!

1. Create a sample PHP file.

2. Get the number of rows of the select result set.

3. Returns the number of rows affected by the last operation.

4. Judge whether there is data or not through the code of sql query function.

Example

/ / method 1: $sql = "select * from `student`where `age` ='16 years;"; $rows = mysql_query ($rs);? > if (mysql_num_rows ($rs)

< 1){ echo '查询无数据!'; }else{ while($rows=mysql_fetch_array($rs)){ ?>

Name: gender: age: grade: class:}}? > / method 2$ sql = "select * from `student`where `age` = '1600;"; $rows = mysql_query ($rs) ? > if (mysql_affected_rows ()) {while ($rows=mysql_fetch_assoc ($rs)) {? > name: gender: age: grade: class:}} else {echo "No data!" At this point, the study of "what is the method for php mysql to judge whether there is data or not" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Tags: Method data study name grade age gender more class help practical next code function example file article query function theory knowledge Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Shulou Information Huawei Microsoft Docker