Count from 2 fields
Posted: Sun Oct 17, 2010 11:20 am
Hi from an beginner, Hope you can help me.
I have a database with a table with name " Owner"
From owner i pic from 2 fields " mc " and " model ".
When I count from "mc" and the works perfect with this code
Question 1
Here I get :
There are 1 alabama
There are 34 Mexico
There are 65 New orleans
There are 34 wales
And so on.....
Question 2
Question 2 works also realy great.
Here I get :
There are 17 USA
There are 110 UK
There are 4 Canada
There are 3 France
And so on.......
Now I want to combine those to and get:
2 in Florida USA
3 in Califonia USA
7 in Wales UK
and so on....
Any who can help a beginner?
Nebbe
I have a database with a table with name " Owner"
From owner i pic from 2 fields " mc " and " model ".
When I count from "mc" and the works perfect with this code
Question 1
Code: Select all
<?php
## database connection!
include ('mysqlcondb.php');
// Make a MySQL Connection
$query = "SELECT *, COUNT(model) FROM owner GROUP BY model";
$result = mysql_query($query) or die(mysql_error());
// Print out result
while($row = mysql_fetch_array($result)){
echo "There are ". $row['COUNT(model)'] ." ". $row['model'] ."";
echo "<br />";
}
?> There are 1 alabama
There are 34 Mexico
There are 65 New orleans
There are 34 wales
And so on.....
Question 2
Code: Select all
<?php
## database connection!
include ('mysqlcondb.php');
// Make a MySQL Connection
$query = "SELECT *, COUNT(mc) FROM owner GROUP BY mc";
$result = mysql_query($query) or die(mysql_error());
// Print out result
while($row = mysql_fetch_array($result)){
echo "There are ". $row['COUNT(mc)'] ." ". $row['mc'] ."";
echo "<br />";
}
?> Here I get :
There are 17 USA
There are 110 UK
There are 4 Canada
There are 3 France
And so on.......
Now I want to combine those to and get:
2 in Florida USA
3 in Califonia USA
7 in Wales UK
and so on....
Any who can help a beginner?
Nebbe