Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Want to generate control labels from table column comments field.
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Harry Jamieson  
View profile  
 More options Oct 22 2012, 12:42 pm
From: Harry Jamieson <hdjamie...@gmail.com>
Date: Mon, 22 Oct 2012 09:42:09 -0700 (PDT)
Local: Mon, Oct 22 2012 12:42 pm
Subject: Want to generate control labels from table column comments field.

Hi,

I'm using FormBuilder 3.08 and I would like to have real labels on my form
instead of just the column names.  I'm thinking that it should be possible
for me to put this label information into the Comments field for each
column in the table.  However....FormBuilder is just giving me labels with
"1" in them.  Here is my code.  I'm on Windows XP SP3 using MySQL 5.2.44
and Active Perl 5.14.2. I've really tried to dig into this on the internet
before asking.....  Here is my code:

#------------------------------------------
# Get Label contents.
#------------------------------------------
$sqlstatement=qq/SELECT column_name, column_comment FROM
information_schema.columns
   WHERE table_name='preferences'
   AND table_schema = 'hypersort';/;

my $label_sth = $dbh->prepare($sqlstatement);
$label_sth->execute() ||
      die "Could not execute SQL statement ... maybe invalid?";

@label_contents=();
while(my($name) = $label_sth->fetchrow_array) {
 push @label_contents, $name;

}

$label_sth->finish;
.
.
.
.
.
. Other stuff....
.
.
#------------------------------------------
# Init new form.
#------------------------------------------
my $form = CGI::FormBuilder->new(
 title => 'HyperSort Default Settings',
             fields => \@pref_fields,
 values => $defs,
 labels => \@label_contents,
 action => '/scripts/conn2.pl',
 submit => [qw/Cancel Update/],
 stylesheet => '/scripts/conn2.css',
        );
.
.
.
.

I'm pretty sure that my problem lies in how I'm getting the data into the
hash.  Any help would be appreciated, as always!

Harry Jamieson


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Norton Allen  
View profile  
 More options Oct 22 2012, 1:33 pm
From: Norton Allen <al...@huarp.harvard.edu>
Date: Mon, 22 Oct 2012 13:35:20 -0400
Local: Mon, Oct 22 2012 1:35 pm
Subject: Re: Want to generate control labels from table column comments field.

On 10/22/2012 12:42 PM, Harry Jamieson wrote:

> #------------------------------------------
> # Init new form.
> #------------------------------------------
> my $form = CGI::FormBuilder->new(
> title => 'HyperSort Default Settings',
>              fields => \@pref_fields,
> values => $defs,
> labels => \@label_contents,
> action => '/scripts/conn2.pl',
> submit => [qw/Cancel Update/],
> stylesheet => '/scripts/conn2.css',
>         );

Harry, According to the documentation
<http://formbuilder.org/download/CGI-FormBuilder-3.08/docs/CGI/FormBui...>,
the 'labels' option takes a hashref, not an arrayref, presumably pairing
the field name with the desired label.

-Norton


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Harry Jamieson  
View profile  
 More options Oct 22 2012, 2:00 pm
From: Harry Jamieson <hdjamie...@gmail.com>
Date: Mon, 22 Oct 2012 11:00:40 -0700 (PDT)
Local: Mon, Oct 22 2012 2:00 pm
Subject: Re: Want to generate control labels from table column comments field.

Hmmmm, down in the quickrefs it says that it can take either...

 # Create form
    my $form = CGI::FormBuilder->new(

       # Important options
       fields     => \@array | \%hash,   # define form fields
       header     => 0 | 1,              # send Content-type?

I've been programming for a long time, but am new to Perl and CGI, and am
still confused about the various fetchrow variations.

Harry


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Norton Allen  
View profile  
 More options Oct 22 2012, 2:08 pm
From: Norton Allen <al...@huarp.harvard.edu>
Date: Mon, 22 Oct 2012 14:10:46 -0400
Local: Mon, Oct 22 2012 2:10 pm
Subject: Re: Want to generate control labels from table column comments field.

On 10/22/2012 2:00 PM, Harry Jamieson wrote:

> Hmmmm, down in the quickrefs it says that it can take either...

>  # Create form
>     my $form = CGI::FormBuilder->new(

>        # Important options
>        fields     => \@array | \%hash,   # define form fields
>        header     => 0 | 1,              # send Content-type?

fields can take either; labels requires a hashref.

> I've been programming for a long time, but am new to Perl and CGI, and
> am still confused about the various fetchrow variations.

I'm not very familiar with the fetch* methods either. I usually skip the
prepare() and execute() steps and use one of the selectall_* methods
instead to return the complete query.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Harry Jamieson  
View profile  
 More options Oct 22 2012, 3:04 pm
From: Harry Jamieson <hdjamie...@gmail.com>
Date: Mon, 22 Oct 2012 12:04:22 -0700 (PDT)
Local: Mon, Oct 22 2012 3:04 pm
Subject: Re: Want to generate control labels from table column comments field.

Opps.  My bad!  Trying to finish the post before lunch.  :(  I guess that I
will just have to play with this some more.  Playing is the best way to
learn...

Harry


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Harry Jamieson  
View profile  
 More options Oct 24 2012, 5:25 pm
From: Harry Jamieson <hdjamie...@gmail.com>
Date: Wed, 24 Oct 2012 14:25:35 -0700 (PDT)
Local: Wed, Oct 24 2012 5:25 pm
Subject: Re: Want to generate control labels from table column comments field.

I've solved this problem, though probably not with the elegance that
someone with more Perl knowledge would have.  I simply read it in as an
array, and this gave me my column_comment information without the spurious
column heading from the schema.

$sql_stmt=qq/SELECT column_comment FROM information_schema.columns
   WHERE table_schema = 'hypersort'
   AND table_name='preferences';/;

$label_sth = $dbh->prepare($sql_stmt);
$label_sth->execute() ||
      die "Could not execute SQL statement ... maybe invalid?";  

while($results=$label_sth->fetchrow_array) {
push @label_contents, $results;

}

$label_sth->finish;
.
.
.
.
.

After this I got my real column names from my actual table into an array,
and built my hash from the two arrays together.

.
.
.
$row=0;
while($pref_fields[$row]) {
 $label_hash{$pref_fields[$row]} = $label_contents[$row];
 $row++;

"$pref_fields" contains my real column names and "$label_contents" contains
what I want the labels to say from each columns "Comments" field.

Thanks for trying to help!

Harry


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »