Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 132759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:18:49+00:00 2026-05-11T06:18:49+00:00

Effectively a duplicate of: How can I display data in table with Perl The

  • 0

Effectively a duplicate of: How can I display data in table with Perl

The accepted answer there applies here. So do some of the alternatives.


I am trying to run raw database queries from Perl program and display results to the user. Something like select * from table. I want to display the information in a HTML table. The columns in the HTML table correspond with the returned columns.

I am having some issues. I can run describe table query to return the number of columns there are in the table. However, how will I store the information from the returned results into arrays?

So if I am storing results like this:

while (($f1, $t2, $n3, $k4, $d5, $e6) = $sth1->fetchrow_array) 

In this case I only know that there are, say four columns (which I got from describe table). But this number four is dynamic and can change depending on the table name. I can not declare my variables based on this number. Any suggestions?

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T06:18:50+00:00Added an answer on May 11, 2026 at 6:18 am

    Try:

    print '<table>\n';  # display HTML header @cols = @{$sth->{NAMES_uc}}; print '<tr>'.join('', map { '<th>${_}</th>' } @cols).'</tr>\n';  # display one HTML table row for each DB row while (my @row = $sth->fetchrow_array) {   print '<tr>'.join('', map { '<td>${_}</td>' } @row).'</tr>\n'; } print '</table>\n'; 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I effectively trace the raw data sent to my socket server listening
I'm effectively trying to have the FlexSlider be hidden, except for some controlling thumbnails.
There are some duplicate (appearing twice or more) combinations of (id, name, dept_name). Note:
How can I update an entity effectively in hibernate just as by using SQL.
I have a method that effectively takes a string. However, there is a very
The dis module can be effectively used to disassemble Python methods, functions and classes
I have a class that is effectively a object based enum. There is a
Possible Duplicate: mySQL “Rank in Highscore”-Query I was just wondering if there is any
I'm trying to implement my own version of vector class without using iterators. Here
Possible Duplicate: Is there a REAL performance difference between INT and VARCHAR primary keys?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.