I have written the following program. The purpose is to read three records and print them accross, and then read another three records and print them until all the records are written. With the logic in my program, it reads and prints one record, and prints it accross the three places. It prints the first record three times but it does not print the picture. Any help will be appreciated.
#!/usr/bin/perl
print "Content-type:text/html\n\n";
#storer.cgi - use with store.html and store.cgi and store.out - item for Sale
open(INF,"store1.out" or dienice("Couldn't open auto.out for reading: $! \n"
print "<h2>ITEMS For Sale</h2>\n";
@data = <INF>;
close(INF);
# First we initialize some counters and hashes for storing the
# summarized data.
$count =0;
$commentary ="";
$d ="\$";
foreach $i (@data) {
$coun=1;
sub_loop;
chomp($i);
($name,$add,$city,$state,$zip,$item,$photo,$size,$color,$price,$email,$tele,
$time,$photo1,$comment,$month,$day,$year)=split(/\|/,$i);
# this is the same as $count = $count + 1;
$count++;
print "$coun\n";
if ($coun=1) {
$name1 = $name;
$add1 = $add;
$city1 = $city;
$state1 = $state;
$zip1 = $zip;
$item1 = $item;
$photo1 = $photo;
$size1 = $size;
$color1 = $color;
$price1 = $price;
$email1 = email;
$tele1 = $tele;
$time1 = $time;
$photo11 = $photo1;
$comment1 = $comment;
$month1 = $month;
$day1 = $day;
$year1 = $year;
print "=1\n";
}
if ($coun=2) {
$name2 = $name;
$add2 = $add;
$city2 = $city;
$state2 = $state;
$zip2 = $zip;
$item2 = $item;
$photo2 = $photo;
$size2 = $size;
$color2 = $color;
$price2 = $price;
$email2 = email;
$tele2 = $tele;
$time2 = $time;
$photo12 = $photo1;
$comment2 = $comment;
$month2 = $month;
$day2 = $day;
$year2 = $year;
print "=2\n";
}
if ($coun=3) {
$name3 = $name;
$add3 = $add;
$city3 = $city;
$state3 = $state;
$zip3 = $zip;
$item3 = $item;
$photo3 = $photo;
$size3 = $size;
$color3 = $color;
$price3 = $price;
$email3 = email;
$tele3 = $tele;
$time3 = $time;
$photo13 = $photo1;
$comment3 = $comment;
$month3 = $month;
$day3 = $day;
$year3 = $year;
print "=3\n";
}
$coun++;
if ($coun<3) {
&loop;
}
print "<table width=\"100%\"> <tr>\n";
print "<td><img src=\"/images/$photo11\" width=\"150\" height=\"150\" align=\"left\" hspace=\"15\"></td>\n";
print "<td><img src=\"/images/$photo12\" width=\"150\" height=\"150\" align=\"left\" hspace=\"15\"></td>\n";
print "<td><img src=\"/images/$photo13\" width=\"150\" height=\"150\" align=\"left\" hspace=\"15\"></td></tr>\n";
print "<tr><td>Item : $item1 <br> Price: <u>$d$price1</u><br>Color: <u>$color1</u> Size: <u>$size1</u><br> Phone:
<u>$tele1</u><br> Time-to-call: <u>$time1</U><br> E-mail: <u>$email1</u><br>\n";
print "Description: $comment1.<br>\n";
print "<td>Item : $item2 <br> Price: <u>$d$price2</u><br>Color: <u>$color2</u> Size: <u>$size2</u><br> Phone:
<u>$tele2</u><br> Time-to-call: <u>$time2</U><br> E-mail: <u>$email2</u><br>\n";
print "Description: $comment2.<br>\n";
print "<td>Item : $item3 <br> Price: <u>$d$price3</u><br>Color: <u>$color3</u> Size: <u>$size3</u><br> Phone:
<u>$tele3</u><br> Time-to-call: <u>$time3</U><br> E-mail: <u>$email3</u><br>\n";
print "Description: $comment3.<br></tr>\n";
print "$coun, $count\n";
&loop1;
}
close INF;
print <<EndHTML;
EndHTML
sub dienice {
my($msg) = @_;
print "<h2>Error</h2>\n";
print $msg;
exit;
}
#!/usr/bin/perl
print "Content-type:text/html\n\n";
#storer.cgi - use with store.html and store.cgi and store.out - item for Sale
open(INF,"store1.out" or dienice("Couldn't open auto.out for reading: $! \n"
print "<h2>ITEMS For Sale</h2>\n";
@data = <INF>;
close(INF);
# First we initialize some counters and hashes for storing the
# summarized data.
$count =0;
$commentary ="";
$d ="\$";
foreach $i (@data) {
$coun=1;
sub_loop;
chomp($i);
($name,$add,$city,$state,$zip,$item,$photo,$size,$color,$price,$email,$tele,
$time,$photo1,$comment,$month,$day,$year)=split(/\|/,$i);
# this is the same as $count = $count + 1;
$count++;
print "$coun\n";
if ($coun=1) {
$name1 = $name;
$add1 = $add;
$city1 = $city;
$state1 = $state;
$zip1 = $zip;
$item1 = $item;
$photo1 = $photo;
$size1 = $size;
$color1 = $color;
$price1 = $price;
$email1 = email;
$tele1 = $tele;
$time1 = $time;
$photo11 = $photo1;
$comment1 = $comment;
$month1 = $month;
$day1 = $day;
$year1 = $year;
print "=1\n";
}
if ($coun=2) {
$name2 = $name;
$add2 = $add;
$city2 = $city;
$state2 = $state;
$zip2 = $zip;
$item2 = $item;
$photo2 = $photo;
$size2 = $size;
$color2 = $color;
$price2 = $price;
$email2 = email;
$tele2 = $tele;
$time2 = $time;
$photo12 = $photo1;
$comment2 = $comment;
$month2 = $month;
$day2 = $day;
$year2 = $year;
print "=2\n";
}
if ($coun=3) {
$name3 = $name;
$add3 = $add;
$city3 = $city;
$state3 = $state;
$zip3 = $zip;
$item3 = $item;
$photo3 = $photo;
$size3 = $size;
$color3 = $color;
$price3 = $price;
$email3 = email;
$tele3 = $tele;
$time3 = $time;
$photo13 = $photo1;
$comment3 = $comment;
$month3 = $month;
$day3 = $day;
$year3 = $year;
print "=3\n";
}
$coun++;
if ($coun<3) {
&loop;
}
print "<table width=\"100%\"> <tr>\n";
print "<td><img src=\"/images/$photo11\" width=\"150\" height=\"150\" align=\"left\" hspace=\"15\"></td>\n";
print "<td><img src=\"/images/$photo12\" width=\"150\" height=\"150\" align=\"left\" hspace=\"15\"></td>\n";
print "<td><img src=\"/images/$photo13\" width=\"150\" height=\"150\" align=\"left\" hspace=\"15\"></td></tr>\n";
print "<tr><td>Item : $item1 <br> Price: <u>$d$price1</u><br>Color: <u>$color1</u> Size: <u>$size1</u><br> Phone:
<u>$tele1</u><br> Time-to-call: <u>$time1</U><br> E-mail: <u>$email1</u><br>\n";
print "Description: $comment1.<br>\n";
print "<td>Item : $item2 <br> Price: <u>$d$price2</u><br>Color: <u>$color2</u> Size: <u>$size2</u><br> Phone:
<u>$tele2</u><br> Time-to-call: <u>$time2</U><br> E-mail: <u>$email2</u><br>\n";
print "Description: $comment2.<br>\n";
print "<td>Item : $item3 <br> Price: <u>$d$price3</u><br>Color: <u>$color3</u> Size: <u>$size3</u><br> Phone:
<u>$tele3</u><br> Time-to-call: <u>$time3</U><br> E-mail: <u>$email3</u><br>\n";
print "Description: $comment3.<br></tr>\n";
print "$coun, $count\n";
&loop1;
}
close INF;
print <<EndHTML;
EndHTML
sub dienice {
my($msg) = @_;
print "<h2>Error</h2>\n";
print $msg;
exit;
}