Show total count of items on page created by views
You could add an element on Header, from the interface.
CLick "Add" in header section and then add a "Global: Result summary" field.

If you have to do it by code, the right variable should be:

$view-&gt;total_rows