Jump to content

While Loop Count


chasethemetal

Recommended Posts

Hey,I have this while loop. That is displaying and counting the 5 most pages viewed. It ends up looking something like this....There are 45 http://www.sitename.com/100.php referring visitsThere are 32 http://www.sitename.com/200.php referring visitsThere are 30 http://www.sitename.com/300.php referring visitsThere are 12 http://www.sitename.com/400.php referring visitsThere are 10 http://www.sitename.com/500.php referring visitsBut what I cant figure out is how to count the loops so the echo'd result looks like....0 There are 45 http://www.sitename.com/100.php referring visits1 There are 32 http://www.sitename.com/200.php referring visits2 There are 30 http://www.sitename.com/300.php referring visits3 There are 12 http://www.sitename.com/400.php referring visits4 There are 10 http://www.sitename.com/500.php referring visitsHeres my current code, any help would be great. Thanks.

while($data = mysql_fetch_array($result)){		echo "There are ". $data['COUNT(fromwhere)'] ." ". $data['fromwhere'] ." referring visits.";	echo "<br />";		}

Link to comment
Share on other sites

I spoke too soon.That actually results in this...0 There are 45 http://www.sitename.com/100.php referring visits1 There are 45 http://www.sitename.com/100.php referring visits2 There are 45 http://www.sitename.com/100.php referring visits3 There are 45 http://www.sitename.com/100.php referring visits4 There are 45 http://www.sitename.com/100.php referring visitshmmm any thoughts...

Link to comment
Share on other sites

So there is one more piece to this puzzle. If $data['fromwhere'] = "" then I don't want it to count it. In my database there are a large amounts of nothing in the fromwhere field, simply because I started filling them in late. So I was wondering if there was a way exclude counting if the fromwhere field is empty. Thanks

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...