jesushax Posted March 10, 2008 Share Posted March 10, 2008 hi below is my code <?php $notes = mysql_query("SELECT COUNT(*) FROM tblCompanyNotes WHERE UserID='".$ID."' ") or die (mysql_error()); $files = mysql_query("SELECT COUNT(*) FROM tblCompanyFiles WHERE UserID='".$ID."' ") or die (mysql_error()); $CNotes = mysql_fetch_array($notes); $CFiles = mysql_fetch_array($files); echo 'You have a total of '.$CNotes.' notes<br />'; echo 'You have a total of '.$CFiles.' files available for download<br />'; ?> and it outputs this You have a total of Array notes You have a total of Array files available for download whats wrong here, can anyone tell me? Cheers Link to comment https://forums.phpfreaks.com/topic/95427-counting-records-by-a-unique-field/ Share on other sites More sharing options...
cytech Posted March 10, 2008 Share Posted March 10, 2008 Maybe: SELECT COUNT(*) as total Then CNotes['total'] Link to comment https://forums.phpfreaks.com/topic/95427-counting-records-by-a-unique-field/#findComment-488542 Share on other sites More sharing options...
jesushax Posted March 10, 2008 Author Share Posted March 10, 2008 now i have <?php $notes = mysql_query("SELECT COUNT(*) as total FROM tblCompanyNotes WHERE UserID='".$ID."' ") or die (mysql_error()); $files = mysql_query("SELECT COUNT(*) FROM tblCompanyFiles WHERE UserID='".$ID."' ") or die (mysql_error()); $CNotes['total']; $CFiles = mysql_fetch_array($files); $CNotes = mysql_fetch_array($notes); echo 'You have a total of '.$CNotes.' notes<br />'; echo 'You have a total of '.$CFiles.' files available for download<br />'; echo $notes; ?> and still, same result Link to comment https://forums.phpfreaks.com/topic/95427-counting-records-by-a-unique-field/#findComment-488547 Share on other sites More sharing options...
trq Posted March 10, 2008 Share Posted March 10, 2008 $CNotes is an array (hence the name of the function mysql_fetch_array). echo 'You have a total of '.$CNotes['total'].' notes<br />'; Link to comment https://forums.phpfreaks.com/topic/95427-counting-records-by-a-unique-field/#findComment-488549 Share on other sites More sharing options...
jesushax Posted March 10, 2008 Author Share Posted March 10, 2008 ahh right i see. Thanks! Link to comment https://forums.phpfreaks.com/topic/95427-counting-records-by-a-unique-field/#findComment-488554 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.