Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^4: [Solved]: Can we use print <<HTML; twice in same file?

by poj (Abbot)
on Aug 25, 2015 at 20:07 UTC ( [id://1139914]=note: print w/replies, xml ) Need Help??


in reply to Re^3: [Solved]: Can we use print <<HTML; twice in same file?
in thread [Solved]: Can we use print <<HTML; twice in same file?

But what is in the name field ?. I ask because you seem to be using the sort order on that field to match the order of input fields on your page.

poj
  • Comment on Re^4: [Solved]: Can we use print <<HTML; twice in same file?

Replies are listed 'Best First'.
Re^5: [Solved]: Can we use print <<HTML; twice in same file?
by Perl300 (Friar) on Aug 25, 2015 at 20:16 UTC
    And "name" column has all those entires for which I have created checkboxes. Like

    (column)Name: average_speed_answer (col)display: Average Speed of Answer

    (column)Name: percent_trunk_usage (col)display: % Trunk Usage

    etc... For example:

    +-------+-------------------------+-------------------------+--------+ | user | name | display | active | +-------+-------------------------+-------------------------+--------+ | admin | average_speed_answer | Average Speed of Answer | 1 | | admin | ivr_call_volume | IVR Call Volume | 1 | | admin | non_outage_call_volume | Non-Outage Call Volume | 1 | | admin | outage_call_volume | Outage Call Volume | 1 | | admin | percent_trunk_usage | % Trunk Usage | 1 | | admin | post_ivr_call_volume | Post-IVR Call Volume | 1 | | admin | pre_ivr_call_volumn | Pre-IVR Call Volume | 1 | | admin | trunk_group_utilization | Trunk Group Utilization | 1 | +-------+-------------------------+-------------------------+--------+

      So when fetched in sorted order $widget[0] will hold the active flag for average_speed_answer not trunk_usage?. Or have you changed the script to use different elements. For example where you had

      if (row[0] eq '1') { print "<td><form><input type="checkbox" name="trunk_usage" value="1" + checked>% Trunk Usage</form></td>";

      is that now

      if ($widget[4] eq '1') { print "<td><form><input type="checkbox" name="trunk_usage" value="1" + checked>% Trunk Usage</form></td>";
      update :

      If you used a hash instead of an array

      my $sql = 'SELECT name,active FROM comm_desk_widget_status WHERE user = ?'; my $sth = $dbh->prepare($sql); $sth->execute('admin'); my %widget=(); while (my ($name,$active) = $sth->fetchrow_array) { $widget{$name} = $active; }

      then you could use

      if ($widget{'percent_trunk_usage'} == 1) { print "<td><form><input type="checkbox" name="trunk_usage" value="1" + checked>% Trunk Usage</form></td>";

      and there would be no chance of getting out of step

      poj

        What you suggested is really useful... speacially in my case where I might have to change the query for diff users...

        With your suggestions I can use user as a variable and one thing less to worry about for me. THanks again

        Yes, I changed exactly as you have mentioned here.

        I wanted to change the order in code so as it shows average_speed_answer first and so on but it would change sequence on webpage to something different than expected. So I assigned $widget[] in aroder to match with the result of DB query.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1139914]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2024-04-24 18:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found