Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

This is an HTML output problem. The key is in those uses you make of CGI.pm's HTML generation methods. What you want presumably (I'm assuming you have one row of data in your example), is a table with each column's label on the top (in the first row of that column) and each subsequent row containing the value for that entry. Here's how the HTML should look:

<tr> <td>Game Name</td> <td>Online Players</td> <td>Avg. Time</td> </tr> <tr> <td>Star Wars</td> <td>blah</td> <td>blah</td> </tr>

Without knowing what %dvalue holds, I'd guess that the 'offending' lines are

print $query->Tr($query->td([$var])); print $query->Tr($query->td(["$dvalue{$var} $dname{$var}"]));

In both cases, you're passing td an anonymous array holding a single value ($var in the first, a concatenation of two hash values in the second). That will print out a single td tag in both cases; and since you've got those wrapped in Tr calls, those end up on two different rows.

What you're getting, in other words is

<tr> <td> ( value of $var )</td> </tr> <tr> <td>(values of the two hash entries )</td> </tr>

You need to work to understand how these functions work, how that code translates to HTML ( or maybe you need to understand more HTML ).

Finally, just because CGI.pm *can* generate HTML doesn't mean you *need* to use it to =) Look into doing things by hand a bit, it may help out here.

perl -e 'print "How sweet does a rose smell? "; chomp ($n = <STDIN>); +$rose = "smells sweet to degree $n"; *other_name = *rose; print "$oth +er_name\n"'

In reply to Re: print output by arturo
in thread Help with CGI.pm's Table commands by swarddb

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2024-04-23 20:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found