mysql - Count rows in the output data sent by a function in php -



mysql - Count rows in the output data sent by a function in php -

the next code in function.php file

function getalldata() { $sql="select * `student`"; $query=mysql_query($sql)or die(mysql_error()); while($row=mysql_fetch_array($query)) { $data[]=$row; } homecoming $data; }

in index.php, task

$data=getalldata(); foreach($data $row) { . .processing xx of xx records . }

i want find out total number of rows query outputs , fill xx in echo statement . please help me php syntax. tried lot of syntax found on net either echos blank (nothing @ all) or echos array , not exact count. give thanks you.

edit: yes, question may had reply @ count number of mysql rows sorry trouble.

then simple as:

$data=getalldata(); $counted = count($data); $i = 1; foreach($data $row) { . .processing $i of $counted records . $i++; }

and! recommend utilize pdo. find documentation here

hope helps! :d

php mysql

Comments

Popular posts from this blog

javascript - THREE.js reposition vertices for RingGeometry -

javascript - I need to update the text of a paragraph by inline edit -

assembly - What is the addressing mode for ld, add, and rjmp instructions? -