I want to sum of OBTAINED MARKS OF related RollNo 1,2,3,4 Etc
When I write RollNo So The All subject came On Table And Sum its ObtainedMarks
This is My Code:- Please Solution

<body>
<br/><br/>
<form action="" method="post" name="form1">
<table width="25%" border="0">
<tr>
<td>RollNo</td>
<td><input type="number" min = 1 name="RollNo"></td>
</tr>
<tr><td>
<?php
$cser=mysqli_connect("localhost","root","","dmc") or die("connection failed:".mysqli_error());
$result = mysqli_query($cser,"SELECT Subject FROM subjects") or die(mysql_error());
if (mysqli_num_rows($result)!=0)
{
echo 'Subject</td><td><select name="Subject">
<option value=" " selected="selected">Choose one</option>';
while($drop_2 = mysqli_fetch_array( $result ))
{
echo '<option value="'.$drop_2['Subject'].'">'.$drop_2['Subject'].'</option>';
}
echo '</select>';
}
?>
</td>
</tr>
<tr>
<td>Name</td>
<td><input type="text" pattern="[a-zA-Z][a-zA-Z ]{2,}" name="Name"></td>
</tr>
<tr>
<td>ObtainedMarks</td>
<td><input type="number" min = 1 name="ObtainedMarks"></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="Submit" value="Enter"></td>
</tr>
</table>
</form>
</body>
</html>
I am not getting your point. Your language is not readable format. Well if you want to sum of obtained marks column data using PHP, then follow this code. It will help you with the sum of all complete columns.
<?php
$cser=mysqli_connect("localhost","root","","test") or die("connection failed:".mysqli_error());
$sql_qry="SELECT SUM(pprice) AS count FROM crud2";
$duration=mysqli_query($cser,$sql_qry);
while($record = $duration->fetch_array()){
$total = $record['count'];
}
echo $total
?>
1. Change MySQL database name (test to your db name ) or do not add this line if you are already added the connection config file.
2. If you want to sum then, change the crud2 table name to your created table name.
3. If you want to sum of obtained marks, change pprice to your obtained marks column name.
I hope, it will you. If the problem will occur, then comment here.
You should use SUM with the MYSQL database column.
Try this code and get the sum of the column.
$sql = mysqli_query($mysqli,"SELECT SUM(column_name) as total FROM table_name");
$row = mysql_fetch_array($sql);
$sum = $row['total']; .
This live website is powered by Techno Smarter QA. The complete source code is now available with a powerful admin panel, responsive design, future updates, and support.