2 messages in com.mysql.lists.perlCounting countries
FromSent OnAttachments
Bruce Therrien20 Sep 2004 05:33 
Jochen Wiedmann20 Sep 2004 05:41 
Subject:Counting countries
From:Bruce Therrien (bruc@wm-mw.org)
Date:09/20/2004 05:33:10 AM
List:com.mysql.lists.perl

Trying to count the number of countries in a MySQL database. Each client has a country entered, and we want to add the total countries we are in and display on our site. The following code is not working correctly. Any help appreciated.....

$SQL =<<SQL; select count(distinct(country)), country as total3 from $tablename SQL $sth = $dbh->prepare($SQL); if(!$sth) { die("Error: " . $dbh->errstr . "\n"); } if(!$sth->execute) { die("Error: " . $sth->errstr . "\n"); }

$match = 0; if($sth->rows != 0) { $total_rows = $sth->rows; $match = 1;

for ($counter = 0; $counter < $total_rows; $counter++) { my($ref) = $sth->fetchrow_hashref;

$totalcountries = $ref->{'total3'};

open(NUM,">$data_directory/country_count.txt"); flock (NUM, 2); print NUM "$totalcountries"; close(NUM); } } $sth->finish();

This is the end of the internet. Please turn around and go back.