Ullswater
House

Links to other websites that we think might be of use to you

Links Page

#!/usr/bin/perl # Updateable Links site scripts # # print_links.cgi # # Outputs the links table # # 02/02/04 by Will Board (will@bfinternet.co.uk) use CGI::Carp qw(fatalsToBrowser); use CGI; use DBI; # load in library files require 'lib.pl'; # create cgi instance $cgi = new CGI; # define html templates $link_html = <<_END;

::link_name::
::link_text::

::link_image::
_END # get links $sql_string = 'SELECT id, link_url, link_name, link_image, link_text FROM links'; # get data from db and place in @data list of hashes @fields = ('id','link_url','link_name','link_image','link_text'); @data = &do_sql_query($sql_string,@fields); $matches = scalar(@data); $counter = 0; while ($counter < $matches) { $links .= $link_html; $links =~ s/::link::/$data[$counter]{'link_url'}/g; $links =~ s/::link_name::/$data[$counter]{'link_name'}/g; if ($data[$counter]{'link_image'}) { $link_string = ""; } else { $link_string = ' '; } $links =~ s/::link_image::/$link_string/g; $links =~ s/::link_text::/$data[$counter]{'link_text'}/g; $counter++; } print $cgi->header(); print $links;