Writing my first module

Hi, I suppose I am looking for someone to help me put together a module I need but that doesn’t seem to be out there.

I have the basics (I think) but I need to know how to put a module together.

I run an international community site and want to add the users home country along with the flag to their profile. So far I have…

A list of 230 countries – courtesy of Wikipedia
A file of 247 flag gifs – courtesy of Fam Fam Fam.
The following bit of code…
And a willingness to learn

Any and all help would be most welcome…

<?
// Array Structure:  "country","flag"

$allqts = array
    (
	"Afghanistan", "af", 
	"Aland Islands", "ax", 
	"Albania", "al", 
	"Algeria", "dz", 
	"American Samoa", "as", 
	"Andorra", "ad", 
	"Angola", "ao", 
	"Anguilla", "ai", 
	"Antarctica", "aq", 
	"Antigua and Barbuda", "ag", 
	"Argentina", "ar", 
	"Armenia", "am", 
	"Aruba", "aw", 
	"Australia", "au", 
	"Austria", "at", 
	"Azerbaijan", "az", 
        );

// Gets the Total number of Items in the array
//  Divides by 2 because there is a country followed by a flag code
$totalcty = (count($allcty)/2);

// Subtracted 1 from the total because '0' is not accounted for otherwise
$nmbr = (rand(0,($totalctys-1)));
$nmbr = $nmbr*2;

$country = $allcty[$nmbr];
         $nmbr = $nmbr+1;
$flag = $allcty[$nmbr];

echo "$country ";
echo "<img src='flags/$flag.gif'>";
?>

Comments

mouse77e’s picture

surely there must be a way to learn this stuff...

davecormier’s picture

Have you looked at the http://drupal.org/node/82920

It gets you out of the gate.

Sree’s picture

You can also try out 'professional drupal development' book ....

-- Sree --
IRC Nick: sreeveturi