forked from GanapriyaS/QuizApp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaverage.php
34 lines (31 loc) · 866 Bytes
/
average.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
$host="localhost";
$username="root";
$password="";
$database="lab3";
try {
$conn= mysqli_connect($host,$username,$password,$database);
if($conn){
}
}catch(Exception $errormsg){
echo $errormsg->getMessage();
die("Error". mysqli_connect_error());
}
if(isset($_POST['updateYourScore']))
{
$sco=$_POST['updateYourScore'];
$update = mysqli_query($conn,"insert into score(mark) values($sco);");
$select = mysqli_query($conn,"SELECT avg(mark) as avg FROM score;");
$row = mysqli_fetch_assoc($select);
$value=$row["avg"];
echo "<p>Your Result is: ".$sco." %</p><p>Median Score is: ".$value." %</p>";
}
if(isset($_POST['updateTotalCount']))
{
$select = mysqli_query($conn,"SELECT tot FROM total;");
$update=mysqli_query($conn,"update total set tot=tot+1;");
$row = mysqli_fetch_assoc($select);
$value=$row["tot"];
echo $value;
}
?>