September 28th, 2000, 04:57 AM
I need to count the rows in a mysql table and to find the max value of a column. I
am selecting count and max with mysql queries, but fail getting the results from my php code. For counting the rows I also tried mysql_fetch_array and then counting the rows in the array, but it didn't work either. Does someone know how to retreive the results of count() and max() ?
Have fun (What else can you do until you die?)
September 28th, 2000, 05:41 AM
you can find out both the things very easily..
if you can issue a select statement like following can get you both count & max
"SELECT count(*) as cnt,max(coulmn) as max_val from tblname";
then you can get the vallues printed very easily..
//select your databasse..
$query="SELECT count(*) as cnt,max(coulmn) as max_val from tblname";
//total records to array..
echo "Total number of record".$rows["cnt"];
echo "Max value of column is ".$rows["max_val"];
//echo "total number of records using mysql number of rows funtion is".mysql_num_rows($result);
you can get the total record using mysql_num_rows() as well..
www.jobxyz.com-IT Career Portal
"The fear of the LORD is the beginning of knowledge..."