Adding a counter to this....

baz_can_fix_it
baz_can_fix_it used Ask the Experts™
on
Hi Experts ....simple problem... I just need to add a counter to this but I keep stuffing it up....Please help

open (ORGDB,"<$database");
@ODB=<ORGDB>;
close (ORGDB);

<table width='100%' border='1'>
<tr><td bgcolor='#F2C973'><font size='2'>No</font></td><td bgcolor='#F2C973'><font size='2'>Actions</font></td><td bgcolor='#F2C973'><font size='2'>Full Name</font></td><td bgcolor='#F2C973'><font size='2'>Phone Number</font></td><td bgcolor='#F2C973'><font size='2'>Vehicle Registration number</font></td></tr>
";
foreach $rec (@ODB){
        chomp($rec);
        ($fullname,$phone,$vrno)=split(/\|/,$rec);
print "<tr><td><font size='2'>count</font></td><td><font size='2'><a href='edit_record.cgi?fullname=$fullname&phone=$phone&vrno=$vrno'>Edit</a> - <a href='edit.cgi?action=delete&fullname=$fullname&phone=$phone&vrno=$vrno'>Delete</a></font></td><td><font size='2'>$fullname</font></td><td><font size='2'>$phone</font></td><td><font size='2'>$vrno</font></td></tr>\n";
}
print "
</table>


Thanx in advanced

Cheers
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
could you explain your question in detail like where you want to add the counter, the question doesn't seem clear
-manas

Author

Commented:
Hi where i have No in the table... i like to see numbers produced underneath for every row of data read from @ODB...

kind of like this


No     Actions     Full Name         Phone Number      Vehicle Registration number
1       edit - del   Mr x                  245678333            123blah
2       edit - del   James Brown    464646464             567hi
3       edit - del     ......
4       ...........
5       .............
6        ............

Cheers

is this ok?

my $count = 1;
foreach $rec (@ODB){
       chomp($rec);
       ($fullname,$phone,$vrno)=split(/\|/,$rec);
print "<tr><td><font size='2'>$count</font></td><td><font size='2'><a href='edit_record.cgi?fullname=$fullname&phone=$phone&vrno=$vrno'>Edit</a> - <a href='edit.cgi?action=delete&fullname=$fullname&phone=$phone&vrno=$vrno'>Delete</a></font></td><td><font size='2'>$fullname</font></td><td><font size='2'>$phone</font></td><td><font size='2'>$vrno</font></td></tr>\n";
         $count++;
}
print "
</table>


or you wanted something else ?
thanks
-manas

Author

Commented:
Mate you are a LEGEND you know what I did wrong...I did exactly same as you but I set my count=0; dehhhhhhhhhhhh hahhahaha silly me......


Thanx Heaps ps I give you extra 100 points if you can solve this one for me...

http://www.experts-exchange.com/Programming/Programming_Languages/Perl/Q_20723315.html

Author

Commented:
well as wel as i left my $ on the count ....

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial