Forum Moderators: coopster & phranque

Message Too Old, No Replies

Database and Perl

         

aline

9:43 pm on Apr 28, 2003 (gmt 0)

10+ Year Member



I have this code that is supposed to print the content of one of my database table. The problem is it prints it 4 times. I've been staring at this very small code for hours and I simply can't see why it is doing that!

#!c:/perl/bin/perl.exe
use DBI;
$,="\t";
use CGI ":standard";
$track=param("track");

print"content-type:text/html\n\n";
print"<html>\n";
print"<body bgcolor=\"fffbec\">";

$db=DBI->connect("dbi:mysql:Web");
$query="select event,surname,nickname from EVENT,ATTENDANCE,PERSON WHERE event='$track' and person=nickname";
$s=$db->prepare($query);
$s->execute();

while(@result=$s->fetchrow())
{
print @result;
}
$s->finish();

$db->disconnect();

Could anyone help?
Thanks

Birdman

9:45 pm on Apr 28, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You may want to try adding DISTINCT to your query.

$query="select DISTINCT event,surname,nickname from EVENT,ATTENDANCE,PERSON WHERE event='$track' and person=nickname";

edited for: typo

[edited by: Birdman at 10:26 pm (utc) on April 28, 2003]

aline

9:48 pm on Apr 28, 2003 (gmt 0)

10+ Year Member



it worked, thank you!