#!/usr/bin/perl
use strict;
use DBI;
use CGI ":all";
use lib qw(/usr/local/modules/);
use birds;
use CGI::Carp qw(fatalsToBrowser warningsToBrowser);
# params
my ($bird) = param('bird');
my ($dothis) = param('dothis');
if (!$dothis) {
$dothis = 1;
}
# html
my ($spaces) = " ";
# start
my ($id) = &birds::lookup("species","id","nospace_name","$bird");
if (!$id) {
$dothis = 0;
}
my ($dbh) = &birds::connect_to_db;
my ($cur,$cur2,$timestamp) = "";
print header,start_html(-title=>"Migrant Bird Stopover Habitat Survey");
print "
Bird Photo Directory\n";
if ($dothis == 0) {
print "some error";
}
if ($dothis == 1) {
my ($dbh) = &birds::connect_to_db;
my ($temp) = "";
$cur = $dbh->prepare("SELECT common_name,latin_name,sort_int,nospace_name,image_c,species_code FROM species WHERE id=$id");
$cur->execute;
$DBI::err and die "Prepare/Execute error: $DBI::err .... $DBI::errstr";
while (my($name,$latin,$sort_int,$nospace,$imgcopy,$scode) = $cur->fetchrow_array) {
$temp = lc $scode;
&make_nav($sort_int,"$temp.html");
print "
$name ($latin) (c) $imgcopy\n";
}
}
print " |
\n";
$dbh->disconnect;
# subs
sub make_nav {
my ($sort_int,$acctfile) = @_;
my ($temp,$temp_name) = 0;
# make the nav table
print "
";
print "\n";
if ($sort_int > 1) {
$temp = ($sort_int - 1);
$temp_name = &birds::lookup("species","nospace_name","sort_int","$temp");
print " | \n";
}
print " | \n";
$temp = ($sort_int + 1);
$temp_name = &birds::lookup("species","nospace_name","sort_int","$temp");
if ($temp_name) { # if we found something
print " | \n";
}
print "
\n\n";
} # end make_nav
# reference
#
#mysql> desc species;
#+--------------+--------------+------+-----+---------+----------------+
#| Field | Type | Null | Key | Default | Extra |
#+--------------+--------------+------+-----+---------+----------------+
#| id | int(11) | NO | PRI | NULL | auto_increment |
#| common_name | varchar(128) | YES | | NULL | |
#| nospace_name | varchar(64) | YES | | NULL | |
#| latin_name | varchar(128) | YES | | NULL | |
#| sort_int | int(11) | YES | | 0 | |
#| species_code | varchar(8) | YES | | NULL | |
#| image_c | varchar(32) | YES | | NULL | |
#| acct_file | varchar(128) | YES | | NULL | |
#| graph_file | varchar(128) | YES | | NULL | |
#| last_update | datetime | YES | | NULL | |
#+--------------+--------------+------+-----+---------+----------------+
#10 rows in set (0.03 sec)
# revisions
# 2/25/2015 - Suzanne - program created