Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: dynamic website, putting data into right tablefield's

by kutsu (Priest)
on Apr 16, 2007 at 16:48 UTC ( #610395=note: print w/replies, xml ) Need Help??


in reply to dynamic website, putting data into right tablefield's

If your having trouble with the hashrefs or arrays, I'd take a look at perldsc for some good examples. As for the html I'd use a template (either HTML::Template or Template Toolkit. I'll leave an example of how to do it in TT, though I might be misreading what your arrays contain.

my $vars = { 'sup' => [ @sup ], 'products' => [ @products ], 'data' => { %data }, #data has the product names as keys ref. an array of data }; $tt->process('sometemplatefile', $vars); <table> [% foreach s = sup %] <tr><td>[% s %]</td></tr> [% end %] [% foreach p = products %] <tr><td>[% p %]</td> [% foreach cur = data.$p %] <td>[% cur %]</td> [% end %] </tr> [% end %] </table>

Replies are listed 'Best First'.
Re^2: dynamic website, putting data into right tablefield's
by ultibuzz (Monk) on Apr 16, 2007 at 20:03 UTC

    Hi,
    thx for the nice example, but i got one question,
    do you have checked if you insert the data in the right spot ?
    i mean if this product and data belongs to sup 1 or 2 or whatever sup or to all the sups.
    i hope i can clearify what i mean with this example table build of the example __DATA__

      1 2
    Product flag data_s data_f data_s data_f
    Promo X 22 106 10 5
    Direct U 1      
    Special U 1 2    

    handling the data is not really a problem, but the right combination of it so it will be in the right place.
    i am thinking to build a row array that has 2 +(sups*2) fields,so the data is in the right place but i stuck at the moment in merging the data together so i dont have 2 rows with Promo for example.
    i don't use html template because i build my own template set in a package, for headers footers dropdowns forms and so on,but this template example looks good and im thinking of it to use it ;)

    kd ultibuzz



    UPDATE:i'm thinking to build a hash based data model to put in the data, somethink like:

    rowhash { Product => { SUP => { DATA_S,DATA_F } SUP => { DATA_S,DATA_F } } Product => { SUP => { DATA_S,DATA_F } SUP => { DATA_S,DATA_F } } }
    then i have all data in the right place.
    i woud start adding all products to this hash stucture then all existing sup's, after that fill in data for the product->sup or leave data blank if no data is there.
    so wahts your opinion
    kd ultibuzz

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://610395]
help
Chatterbox?
[1nickt]: How old are your sprogs marto?
[marto]: 4, if they're good they#ll make it to 5 :P
[1nickt]: Mpph didn;t have twins bu I remember thinking that the "terrible twos" was a misnomer as age 4 seemed to be much more difficult.
LanX 4 kids and wanting to upgrade to 5? wow! ! !
[1nickt]: My lads are 15 and 31 now and both drive me just as crazy as when little, just less frequently.

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (9)
As of 2017-11-18 18:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (277 votes). Check out past polls.

    Notices?