?
Solved

Data in a Table using Cgi.pm and perl      ( approching a deadline)

Posted on 2004-11-18
12
Medium Priority
?
646 Views
Last Modified: 2013-12-25
Sorry  if the question is very trivial ..but please bare with me ( closing on a deadline..I hope u understand).
I tried a lot but my head seems to have given up .( I guess the nerves...I left this for the last )



I have got the functionality going but th presentation is not resulting in what I intend to.
I am using the CGI.pm module with Perl

I intend something like this..display the UserName and a string (MD5 algor) one beside the other
preferrable in a table


UserName1      yututiu67jhkjkjkjkkj
UserName2       jkjkjkkjkj5555555555


What I get is

UserName1
UserName2

yututiu67jhkjkjkjkkj
jkjkjkkjkj5555555555

The code( faulty) code that gets the above is this where the hashes have the values .

####################################################################################
print $page->start_Tr();
   print $page->start_td();
         print $page->start_table({-border=>2});
                for($i=0;$i<@user_sysuids;$i++){  # Iterates through the Number Of users

                        $page->start_Tr();
                       
                        print $page->start_td($user_names{$user_sysuids[$i]});  # The user Name
                        $page->end_td();
                   
                        print $page->start_td($user_keys{$user_sysuids[$i]});     # The Key
                     
                        $page->end_td();
                        $page->end_td();
                        $page->end_Tr();

                }
           print $page->end_table();

          print $page->end_td();
          $page->end_Tr();

###########################################################################################

Thanks for your time...
0
Comment
Question by:micro_learner
  • 7
  • 2
  • 2
  • +1
12 Comments
 
LVL 1

Expert Comment

by:wilsone
ID: 12616764
You are inconsistent with your use of end_td and start_td methods (etc).  This does not look like standard perl CGI methods, but I think you forgot some print statements.  Try this:

print $page->start_Tr();
   print $page->start_td();
         print $page->start_table({-border=>2});
                for($i=0;$i<@user_sysuids;$i++){  # Iterates through the Number Of users

                        print $page->start_Tr();
                       
                        print $page->start_td($user_names{$user_sysuids[$i]});  # The user Name
                        print $page->end_td();
                   
                        print $page->start_td($user_keys{$user_sysuids[$i]});     # The Key
                     
                        print $page->end_td();
                        print $page->end_td();
                        print $page->end_Tr();

                }
           print $page->end_table();

          print $page->end_td();
          print $page->end_Tr();
0
 
LVL 1

Expert Comment

by:wilsone
ID: 12616782
By the way, paste the resulting HTML if the above does not work.
0
 
LVL 1

Expert Comment

by:wilsone
ID: 12616866
Correction: This is just a different way of using the CGI module than I am accustomed to.
0
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

 

Author Comment

by:micro_learner
ID: 12616946
Hi "wilsone" not having the "print" satatemsnts was a blatant error...but it still does not work with it.

I think I am placing the td and Tr combinations wrong ..I need to get the UserName on the  left and the key on the Right.

I appreciate your effort and time.Thanks

I am still getting

UserName1
UserName2

yututiu67jhkjkjkjkkj
jkjkjkkjkj5555555555

Instad of
UserName1     yututiu67jhkjkjkjkkj
UserName2       jkjkjkkjkj5555555555
0
 
LVL 1

Expert Comment

by:wilsone
ID: 12617191
Try this:

my $users;
for($i=0;$i<@user_sysuids;$i++){  # Iterates through the Number Of users
    $users = Tr(td($user_names{$user_sysuids[$i]}).td($user_keys{$user_sysuids[$i]}));
}
print table({-border=>2},$users);

Please post the html if this doesnt work.
0
 
LVL 1

Assisted Solution

by:wilsone
wilsone earned 600 total points
ID: 12617205
Argh, that should be
    $users .= Tr(td($user_names{$user_sysuids[$i]}).td($user_keys{$user_sysuids[$i]}));

Need more coffee
0
 
LVL 48

Accepted Solution

by:
Tintin earned 800 total points
ID: 12619831
I personally don't like using the CGI module for generating HTML.  I think it is clearer and easier to do it yourself or to use one of the templating modules.

I'd do something like:

print qq[<table border="2">\n];

foreach my $uid (@user_sysuids) {
   print qq[<tr><td>$user_names{$uid}</td><td>$user_keys{$uid}</td></tr>\n];
}

print "</table>\n";
0
 
LVL 1

Expert Comment

by:wilsone
ID: 12620772
Thats funny TinTin.  The CGI module is awesome.  Which templating modules are you referring to?
0
 
LVL 48

Expert Comment

by:Tintin
ID: 12621007
What do you find funny?  The idea that a CGI module should have a whole bunch of HTML functions in it?  One of the critisms of the CGI module was that it tried to do too much.  At least the later versions are more modular now.

For templating see:

http://perl.apache.org/docs/tutorials/tmpl/comparison/comparison.html

0
 
LVL 51

Assisted Solution

by:ahoffmann
ahoffmann earned 600 total points
ID: 12626510
print $page->start_table({-border=>2}),$page->Tr([$page->td([$user_names{$user_sysuids[$i]},$user_names{$user_keys[$i]}])]),$page->end_table;
0
 
LVL 1

Expert Comment

by:wilsone
ID: 12626621
ahoffman, I think we need all of the users in one table, not a table per user.  Add a loop.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 12628570
should not be a problem ta add a simple loop here ;-)
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you get a (Blue Screen of Death), your system writes a small file called a minidump. Your first step is to make certain your computer is setup to record memory dumps. Right click My Computer, choose properties. Click on the advanced tab, an…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses
Course of the Month15 days, 22 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question