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:e开发者_StackOverflown111 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'];
精彩评论