| | |
problem with count and displaying result
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Nov 2008
Posts: 2
Reputation:
Solved Threads: 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???
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 Syntax (Toggle Plain Text)
<?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 ; ?>
Last edited by peter_budo; Nov 8th, 2008 at 6:58 pm. Reason: Correcting tags, please use [code] not <code>
hello..see this:
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.
PHP Syntax (Toggle Plain Text)
$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'];
thank you.
Be intelligent, But Don't try to cheat.. Be innocent But Don't get cheated..
•
•
Join Date: Nov 2008
Posts: 2
Reputation:
Solved Threads: 0
•
•
•
•
hello..see this:
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..PHP Syntax (Toggle Plain Text)
$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'];
thank you.
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
php Syntax (Toggle Plain Text)
$query="SELECT count(*) FROM stats WHERE BirthCountry = ".$country." ;";
Regards.
Last edited by peter_budo; Nov 12th, 2008 at 5:22 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
IF SOMEONE FEELS THAT THEY HAD NEVER MADE A MISTAKE IN THEIR LIFE, THEN Â IT MEANS THEY HAD NEVER TRIED A NEW THING IN THEIR LIFE
•
•
Join Date: Oct 2008
Posts: 2
Reputation:
Solved Threads: 0
PHP Syntax (Toggle Plain Text)
$query="SELECT count(*) as c FROM stats WHERE BirthCountry ='$country'";
![]() |
Similar Threads
- PHP MYSQL Paging Problem (PHP)
- Problem of abruptly termination... (C++)
- pagination not displaying results (PHP)
- How to export data from mysql into fields in excell (PHP)
- simple cash register (pos) problem - please help!! (VB.NET)
- trouble with counting letter from file, please help. (C++)
- Help with a reservation program! GUI Messed XD (Java)
- Problem While Processing A String List (C++)
Other Threads in the PHP Forum
- Previous Thread: anti spam contact form
- Next Thread: Semi-automated email script
| Thread Tools | Search this Thread |
# 5.2.10 alexa apache api array beginner binary broken cakephp checkbox class clean clients cms code cron curl database date directory display dissertation dynamic echo echo$_get[x]changingitintovariable... email encode error fairness file files folder form forms function functions google href htaccess html image images include indentedsubcategory insert ip javascript joomla legislation limit link local login mail memberships menu mlm multiple multipletables mysql mysqlquery newsletters oop open paypal pdf persist php problem provider query radio random recursion remote rss script search server sessions simple sms sockets source space spam sql syntax system table tutorial update upload url validator variable video web youtube






