Help
Spent HOURS on this and cannot see the problem.
It will display the country but not the number of clients that are within that country???

<?php

//Retrieve the "count" for the number of people in the specified country

$country= $_POST['totalbycountry'];

//Connect to the server...$connect will contain the connection object

$connect = mysql_connect("localhost:3636", "root","");

//Connect to the relevant Database

$db=mysql_select_db("census",$connect);

//Set up the SQL statement in a variable with a WHERE clause

$query="SELECT count(*) FROM stats WHERE BirthCountry = country";

//Perform the SQL query against the database

$result=mysql_query($query);


echo "The total number of people who were born in " .$country ;

?>

hello..see this:

$query="SELECT count(*) as c FROM stats WHERE BirthCountry = country";

//Perform the SQL query against the database

$result=mysql_query($query);
$row=mysql_fetch_array($result);
echo $row['c'];

i don't know the query for counting no.of clients...but the above is the correct syntax...if this is not correct,post your table structure..
thank you.

hello..see this:

$query="SELECT count(*) as c FROM stats WHERE BirthCountry ='country'";

//Perform the SQL query against the database

$result=mysql_query($query);
$row=mysql_fetch_array($result);
echo $row['c'];

i don't know the query for counting no.of clients...but the above is the correct syntax...if this is not correct,post your table structure..
thank you.

Thanks
This work fine if you put single quotes around 'country'.
If you dont no result is displayed
Thanks again
Castlelaker

Thanks
This work fine if you put single quotes around 'country'.
If you dont no result is displayed
Thanks again
Castlelaker

This should be the correct statement I suppose:

$query="SELECT count(*) FROM stats WHERE BirthCountry = ".$country." ;";

Regards.

$query="SELECT count(*) as c FROM stats WHERE BirthCountry ='$country'";
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.