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

 

UK Electronic Designer
USEFUL?
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.

Comments

Your email address will not be published.