MiniVend Akopia Services

[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date ][Minivend by thread ]

Re: DB Headings -solved



******    message to minivend-users from August Detlefsen <augustd@idiom.com>     ******

> Is there a way to get a list of all the DB column headings? I want to create a page that just outputs a simple table of every row and every column of the database. The rows are easy, but is there a way to automatically grab all the column headers?

This is the solution I used. If anyone has a simpler/more efficient solution, please tell me.

in Minivend.cfg:

GlobalSub <<EOF
sub db_heads2 {
 
   my $table = shift();
   my $heads = '';
 
   open (TABLE, "$table") or return "Can't open table \($table\): $!";
   while (<TABLE>) {
     $heads = $_;
     close TABLE;
   }
   $Vend::Session->{'scratch'}->{'heads'} = $heads;
   return;
}
EOF

in my page:

[perl arg=sub]db_heads2('/path/to/file/database.asc');[/perl]

<TABLE BORDER=1>
<TR>
[loop arg="[scratch heads]"]
<TH ALIGN=center VALIGN=middle>[loop-code]</TD>
[/loop]
</TR>
[tag each products]
<TR>
[loop arg="[scratch heads]" with="-a"]
<TD ALIGN=center VALIGN=middle>[field name="[loop-code-a]" code=[loop-code]]</TD>
[/loop]
</TR>
[/tag]
</TABLE>

That's it. It outputs a nice html table with every entry in your DB. Currently only tested on products.asc, and that [tag each products] will have to change to use it elsewhere.

-August
--
August Detlefsen - Internet Consultant - Web Designer
  mailto:augustd@idiom.com
-
To unsubscribe from the list, DO NOT REPLY to this message.  Instead, send
email with 'UNSUBSCRIBE minivend-users' in the body to Majordomo@minivend.com.
Archive of past messages: http://www.minivend.com/minivend/minivend-list


Search for: Match: Format: Sort by: