0

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 ;

?>
4
Contributors
4
Replies
5
Views
8 Years
Discussion Span
Last Post by jyothi chundi
0

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.

0

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

0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.