This topic is locked
[SOLVED]

 DB::Query row count

5/22/2018 12:50:02 AM
PHPRunner General questions
H
headingwest author

Hello,
After performing DB::Query how do I count the number of rows? I need to do this before "while( $data = $rs->fetchAssoc() )"
So

$rs = DB::Query("select * from carsmake");



IF MORE THAN ZERO ROWS RETURNED DO SOMETHING ONCE HERE
while( $data = $rs->fetchAssoc() )

{

echo $data["id"];

echo $data["make"];

}


Thanks.

admin 5/22/2018

You need to perform a separate query first to get the number of records.

select count(*) from carsmake