Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
First off all I suggest you to use HTML::Template or one of the other popular templating systems to separate code from content. You print a table for each record you receive - maybe it would be better to print just new table-rows for each of them. If you want your users to be able to edit those recordsets again you could create a html-form for each recordset, display them in input-tags and add a submit button. Based on the action you receive via CGI your script will display/add or edit records.

UPDATE:

An example CGI app of my own to show you a way to structure such an app:

#!/usr/bin/perl use strict; use warnings; use CGI; use CGI::Carp qw ( warningsToBrowser fatalsToBrowser ); use DB::Countries; use Templating::Countries; use Query::Countries; # # declaration # my $q = new CGI; my $form = $q->Vars(); my $db = new DB::Countries; my $tmpl = new Templating::Countries; my $dispatch = { 'search' => sub { my $query = new Query::Countries ($form); $tmpl->overview($db->get($query)); }, 'edit' => sub { $tmpl->edit($db->get($form->{'id'})); }, 'new' => sub { $tmpl->add(); }, 'delete' => sub { $tmpl->del($db->get($form->{'id'})); }, 'update' => sub { $db->update($form); $tmpl->default(); }, 'insert' => sub { $db->insert($form); $tmpl->default(); }, 'remove' => sub { $db->remove($form->{'ID_country'}); $tmpl->default(); }, 'default' => sub { $tmpl->default() }, }; # # main # print $q->header(); print $dispatch->{$form->{action}} ? $dispatch->{$form->{action}}() : $dispatch->{'default'}(); exit;
You can see that the app is reduced to a dispatch and just a few lines of code. Everything else is seperated in modules. One for all database-action, one for building queries and one for the templating. Based on the $form->action it receives it calls the related actions using the dispatch table.

In reply to Re: Editing Posted Data by neniro
in thread Editing Posted Data by ejx2

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2024-04-25 06:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found