This is PHP4 Code!

Get Number of Results


 	$query1 = @mysql_query("SELECT COUNT(*) FROM some_table WHERE some_column != 1");
  $number_of_rows = @mysql_fetch_array($query1);
	$number_of_rows = $number_of_rows[0];
	echo "This many: $number_of_rows";

 

Results Based On An Average Score Calculation


$query1 = @mysql_query("SELECT 
		university_name, 
		CONVERT((score / games_played), UNSIGNED INTEGER) as ave_score
	FROM tbl_universities 
	ORDER BY ave_score DESC, university_name ASC");
	//CONVERT only needed if you want the values converted from floats to integers before the sort, use "(score / games_played) as ave_score" otherwise
$count = mysql_num_rows($query1);
while ($result1 = @mysql_fetch_array($query1))    //Get each row returned
{
	$university_name = $result1['university_name'];
	$ave_score = intval($result1['ave_score']);		//intval needed as zero results will come in as null

 

Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

Your email address will not be published. Required fields are marked *