Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

How to get all the fields?

Quote Reply
How to get all the fields?
For another mod, i tried to get all the fields of all links. Someone know how to do this?

What should done?
1. Get all links with e.g. the same e-mail and print them to mail.


Robert

Quote Reply
Re: How to get all the fields? In reply to
How about:

my $results = $db->query ( 'Contact_Email' => 'a@a.com', ww => 1 );
if ($db->hits) {
foreach my $link (@$results) {
$link = $db->array_to_hash($link);
... # do whatever you want with it.
}
}

Hope that helps,

Alex
Quote Reply
Re: How to get all the fields? In reply to
Thank you Alex (for the ID in mail, too)-

i tried the following. My perl-checker says 'code correct', but i can´t call the script from a form with input field name=sendto in it.

May help me on my faults, please.

Code:
#!/usr/bin/perl
# ==============================================================
# -------------
# Links SQL
# -------------
# Links Manager
#
# Author: Alex Krohn
# Email: alex@gossamer-threads.com
# Web: http://www.gossamer-threads.com/
# Version: 1.11
#
# COPYRIGHT NOTICE:
#
# Copyright 1999 Gossamer Threads Inc. All Rights Reserved.
# No redistribution of this script may be made without prior
# written consent.
#
# By using this program you agree to indemnify Gossamer Threads
# Inc. from any liability.
#
# Please see the README for full license details.
#
# ==============================================================

# Load required modules.
# ---------------------------------------------------
use strict;
use CGI ();
use CGI::Carp qw/fatalsToBrowser/;
use lib 'admin';
use Links;
use Links: B_Utils;
use Links::HTML_Templates;
use Links: BSQL;
$|++;

&main();

sub main {
# --------------------------------------------------------

# Your admin email address. Do not delete the \ (backslash).


#Your mail program
$MAIL_PROGRAM="/usr/sbin/sendmail -t";

my $admin="webmaster\@handwerksfuehrer.de";
my $in = new CGI;
my $dynamic = $in->param('d') ? $in : undef;

if ($in->param('sendto')) {

# Varible passed from the form
my $email = $in->param('sendto');

&process_form ($email, $in, $dynamic);
}
else
{
&site_html_error ( { error => "Falscher Aufruf!" }, $dynamic);
}
}

sub process_form {

my $count = 0;

# Make sure we have an email address to send the info to
if (!$email) {
&site_html_error ( { error => "Bitte springen Sie zurück und geben eine E-Mail-Adresse ein!\n" }, $dynamic);
}
else
{
my $results = $db->query ( 'Contact_Email' => '$email', ww => 1 );
if ($db->hits) {

## open mail if something to mail

open (MAIL_RECIP, "|$MAIL_PROGRAM");
print MAIL_RECIP "To: $email\n";
print MAIL_RECIP "From: $admin\n";
print MAIL_RECIP "Subject: Ihre Anfrage auf handwerksfuehrer.de\n";
print MAIL_RECIP "Sie haben nach Ihren Einträgen auf handwerksfuehrer.de\nzur E-Mail-Adresse $email angefragt.\n\n";

## write link-data for every link

foreach my $link (@$results) {
$link = $db->array_to_hash($link);

print MAIL_RECIP "ID: $link->{'ID'}\n\n";
print MAIL_RECIP "Kontakt Name: $link->{'Contact_Name'}\n";
print MAIL_RECIP "Kontakt E-Mail: $link->{'Contact_Email'}\n";
print MAIL_RECIP "Passwort: $link->{'Password'}\n\n";
print MAIL_RECIP "Rubrik: $link->{'Category'}\n";
print MAIL_RECIP "Überschrift: $link->{'Title'}\n";
print MAIL_RECIP "Anzeigentext:/n $link->{'Description'}\n\n";
print MAIL_RECIP "Name: $link->{'Name'}\n";
print MAIL_RECIP "Adresse: $link->{'Strasse'}\n";
print MAIL_RECIP "PLZ Ort: $link->{'PLZ'} $link->{'Ort'}\n\n";
print MAIL_RECIP "Telefon: $link->{'Telefon'}\n";
print MAIL_RECIP "Telefax: $link->{'Telefax'}\n";
print MAIL_RECIP "E-Mail: $link->{'Email'}\n";
print MAIL_RECIP "Suchbegriffe:/n $link->{'Email'}\n";
print MAIL_RECIP "______________________________________\n\n";

$count++;

if ($count ne 1) {
print MAIL_RECIP "Es sind insgesamt $count Einträge für diese E-Mail-Adresse vermerkt.\n\n";
}
print MAIL_RECIP "\n\nMit freundlichen Grüßen\n\n";
print MAIL_RECIP "Robert Emmerich\n";
print MAIL_RECIP "webmaster\@handwerksfuehrer.de\n\n";
print MAIL_RECIP "______________________________________\n";
print MAIL_RECIP "Finden Sie logisch leicht Ihren Handwerker\n";
print MAIL_RECIP "auf http://www.handwerksfuehrer.de\n";
close(MAIL_RECIP);

# Prints Confirmation

&site_html_error ( { error => "Alle Daten für die E-Mail-Adresse <b>$email</b> wurden verschickt!" }, $dynamic);

}#results
}#hits
}#else
}#sub