Jump to content

PHP SQL Count


Call-911

Recommended Posts

Hey All,

 

I need to count and display the number of rows I have.

 

 

<?php

 

//declare the SQL statement that will query the database

$query = "

SELECT COUNT(id) FROM connectvisits

WHERE staffid = '$staffid'

";

 

//execute the SQL query and return records

$result = mssql_query($query);

 

$thismonth = mssql_num_rows($result);

 

echo "Total Meetings This Month: ";

echo $thismonth;

echo "<br />";

 

?>

 

 

For some reason I keep getting a result of 1. Everything else I try gives me a "Resource ID" number. Any help would be apprecaited. Maybe I have the completely wrong code. Thanks!

Link to comment
https://forums.phpfreaks.com/topic/248904-php-sql-count/
Share on other sites

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.