Log in

View Full Version : Count and rows code



rhodarose
12-13-2010, 01:44 AM
What is the explanation or meaning of this code:



$totalarr = count($opname) - 1;


and



$totalrows = mysql_num_rows($result);
$trows = $totalrows - 1;


Thank you

Nile
12-13-2010, 01:48 AM
count() (http://php.net/manual/en/function.count.php) counts the number of elements in an array



$array = array('Dog', 'Cat', 'Apple', 'Pear');
echo count($array); // 4


mysql_num_rows() (http://us3.php.net/manual/en/function.mysql-num-rows.php) returns the amount of returned rows from a query.

rhodarose
12-13-2010, 01:59 AM
count() (http://php.net/manual/en/function.count.php) counts the number of elements in an array



$array = array('Dog', 'Cat', 'Apple', 'Pear');
echo count($array); // 4


mysql_num_rows() (http://us3.php.net/manual/en/function.mysql-num-rows.php) returns the amount of returned rows from a query.

and why the totalrows result need minus 1?

Nile
12-13-2010, 02:07 AM
It depends on where it's being used - it's just subtracting one away probably for a reason that comes up later in the script. I dont know.