Total of records in phpmysql report

Hi! I am trying to generate small report as per attached image. every thing is working fine but i am unable to generate total in the end . I used Rollup to get reuslt but its isnt serve my purpose. Is there any other method by which i can generate total at the end of report. here is my code

                    // Attempt select query execution
                  $sql = "SELECT * FROM mis6";
                    if($result = mysqli_query($link, $sql)){
                        if(mysqli_num_rows($result) > 0){
                            echo '<table class="styled-table">';
                                echo "<thead>";
                                    echo "<tr>";
					echo "<th>Name</th>";
					echo "<th>Marks</th>";
					echo "<th>Total Marks</th>";									
                                        echo "<th>Add Bill</th>";
                                    echo "</tr>";
                                echo "</thead>";
                                echo "<tbody>";
                                while($row = mysqli_fetch_array($result)){
                                    echo "<tr>";
                                        echo "<td>" . $row['name'] . "</td>";
                                        echo "<td>" . $row['marks'] . "</td>";
					echo "<td>" . $row['totalmarks'] . "</td>";                                    
                                    echo "</tr>";
                                echo "</tbody>";                            
                            echo "</table>";
                            // Free result set
                        } else{
                            echo '<div class="alert alert-danger"><em>No records were found.</em></div>';
                    } else{
                        echo "Oops! Something went wrong. Please try again later.";

final output

…add the marks to a total variable as you walk through the loop?


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.