简体   繁体   中英

how can i count the no. of entries in MySQL database using php?

I need to know if the students have a failing grade i have created a databse which contains tables: students(student id,Name), Subject(Subject code,subject description), and grade(grade,subject code,student id).. i created inner join to join the 3 tables. but i need to count the of entries in the table grade for example. Grade: 5 studentID:01 SubjectCode:en111 and another entry Grade: 1 studentID:01 SubjectCode:en111. i want to determine if the student has a double entry so that i can know if he has a failing grade.

SQL_CALC_FOUND_ROWS may help you in this case, you insert it just after SELECT and before *. This will do a count even with a limit on the query.

Then to call the count, you do this.

$sql = 'SELECT FOUND_ROWS() as found_rows '; $rows = $mysql_conn->query_first($sql); $search['count'] = $rows['found_rows'];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM