Help for this page

Select Code to Download


  1. or download this
    my $sth_1 = $dbh->prepare("SELECT * FROM vote WHERE item_no='$last_ite
    +m'");
    $sth_1->execute();
    ...
    #### Define variables from the mySQL output.
    my $description = $row[4];
    my %results = ("$row[5]","$row[11]","$row[6]","$row[12]","$row[7]","$r
    +ow[13]","$row[8]","$row[14]","$row[9]","$row[15]","$row[10]","$row[16
    +]");
    
  2. or download this
    #### Turn the output into percentages.
    my $total = $results{"$row[5]"} + $results{"$row[6]"} + $results{"$row
    +[7]"} + $results{"$row[8]"} + $results{"$row[9]"} + $results{"$row[10
    +]"};
    ...
    $results{"$row[8]"} = ($results{"$row[8]"} / $total) * 100;
    $results{"$row[9]"} = ($results{"$row[9]"} / $total) * 100;
    $results{"$row[10]"} = ($results{"$row[10]"} / $total) * 100;