Hi,i have a table like this :

<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <meta charset="UTF-8">

        <title></title>
        <style>
    table{border-collapse: collapse;}
    tr th, tr td{border: 1px solid black;}
   #resize
   {
       width :100%;
       position: relative;
   }
</style>
    </head>
    <body>

        <?php



    $rows = 10;
$columns = 6; //count of cols from WP to PR
$table = '';
for($r=0;$r<$rows;$r++) {
    $table .= "<tr><td>K" . str_pad(($r+1),3,'0',STR_PAD_LEFT) . "</td>".'<th></th>';
    for($c=0;$c<$columns;$c++){
        $table .= "<td>".mt_rand(1,100)."</td>";


    }
    $table .= '</tr>';



     //$table.='</th>';


}
       ?>
        <?php

       $val= $_GET(['knum']);
       echo $val;
        ?>

    <div id="resize">
    <table width ="100%" class="t1">
        <tr>
            <th id="knum">knumber</th>
            <th>Average</th>
            <th>WP</th>
            <th>WD</th>
            <th>ID</th>
            <th>DV</th>
            <th>HC</th>
            <th id="avr">PR</th>


        </tr>
        <tr></tr>

        <?=$table?>
    </table>

</div>


    </body>
</html>

how would i apply jquary or java script to find average for each of the rows? Thanks

Recommended Answers

Hi librarycode,

please give us some clarity on your code. so that we can give a best way to solve/guide your question [like how the output will be or your code result is like this or ...etc]

thanks

Jump to Post

All 4 Replies

Hi librarycode,

please give us some clarity on your code. so that we can give a best way to solve/guide your question [like how the output will be or your code result is like this or ...etc]

thanks

Sorry for confusion,my question is: have the html table with random numbers,how would i calculate an average of each row?

Appologies

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.