#!/usr/bin/perl # # Make sure you change FIELDNAME to the name of the new field that you've added in the Links table. # Also, change the two admin paths. # use CGI; use strict; use lib '/path/to/admin'; #change use Links qw/$CFG $IN $DB $USER/; Links::init('/path/to/admin'); #change Links::init_user(); my $cat_tb=$DB->table('Category','CatLinks'); my $table=$DB->table('Links'); my ($sth,$sth2); print $IN->header; #lookup each link in the category database and update the field $sth=$table->select(['ID'],{FIELDNAME=>''}); while (my $LinkID=$sth->fetchrow_array){ #loop up the link in Category and update field $sth2=$cat_tb->select(['Name'],{LinkID=>$LinkID}); my $fieldfiller=''; while (my $name=$sth2->fetchrow_array){ $fieldfiller.="$name, "; } $table->update({FIELDNAME=>$fieldfiller},{ID=>$LinkID}); print "$LinkID updated
\n"; } 1;