now my code is running but output is not correct I am getting 'q' for all label in first row of table (TK) and '1' for all label in the second row of the same table

Yes, I ran it and got the same results as you. I (mistakenly) thought that my $row = $sh2->fetchrow_arrayref provided a fresh instance of $row to push onto the @name array. I confess I'm not really sure what is happening or why. It seems that all entries in the array are the last entry. Perhaps someone else could explain this better.

To get the correct info, I made the change below.

#!/usr/bin/perl use strict; use warnings; use DBI; my $dbh = DBI->connect("dbi:SQLite:dbname=users.lite","","", or die "Can't connect"; my $sh2=$dbh->prepare("select code,name from level "); $sh2->execute() or die(); my @name; while (my @row = $sh2->fetchrow_array) { push @name, [@row]; } $dbh->disconnect or die $!; for my $i ( 0 .. $#name) { print "code: $name[$i][0] name: $name[$i][1]\n"; } __END__ *** the program prints code: 001 name: Level1 code: 002 name: Level2 code: 003 name: Level3 code: 004 name: Level4 code: 005 name: Level5 code: 006 name: Level6 code: 007 name: Level7 code: 008 name: Level8 code: 009 name: Level9 code: 0010 name: Level10 code: 0011 name: Level11

In reply to Re^3: Fetch data from DB and put in to Table Tk by Cristoforo
in thread Fetch data from DB and put in to Table Tk by gocpon

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.