Advertisement
Guest User

Untitled

a guest
Oct 17th, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.23 KB | None | 0 0
  1. OPERAHAN NYO NALANG.
  2.  
  3. ------------------------------------------------------------------------------------------------
  4. index.php
  5. ------------------------------------------------------------------------------------------------
  6. <?php
  7. include "db/conn.php";
  8. $fname = $lname = $mname = $course = $attendance = $exercise = $quiz = $exam = $finalGrade ="";
  9.  
  10. if(isset($_POST['register'])){
  11.  
  12. $fname = $_POST['fname'];
  13. $lname = $_POST['lname'];
  14. $mname = $_POST['mname'];
  15. $course = $_POST['course'];
  16. $attendance = $_POST['attendance'];
  17. $exercise = $_POST['exercise'];
  18. $quiz = $_POST['quiz'];
  19. $exam = $_POST['exam'];
  20.  
  21. $fattendance = (($attendance/90)*.10)*100;
  22. $fexercise = (($exercise/100)*.25)*100;
  23. $fquiz = (($quiz/100)*.25)*100;
  24. $fexam = (($exam/200)*.40)*100;
  25. $finalGrade = ($fattendance+$fexercise+$fquiz+$fexam);
  26.  
  27. $sql = mysqli_query($conn, "INSERT INTO tbl_info (firstName,lastName,middleName,course,attendance,exercise,quiz,exam,finalGrade)"."VALUES
  28. ('$fname','$lname','$mname','$course','$attendance','$exercise','$quiz','$exam','$finalGrade')");
  29.  
  30. }
  31.  
  32. ?>
  33.  
  34.  
  35. <html>
  36. <header>
  37. <title></title>
  38. </header>
  39. <body>
  40.  
  41.  
  42. <div class="body-content">
  43. <div class="module">
  44. <h1>Create an account</h1>
  45. <form class="form" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post">
  46. <label>First Name</label><input type="text" name="fname" value="<?php echo $fname ?>" />
  47. <label>Last Name</label><input type="text" name="lname" value="<?php echo $lname ?>" />
  48. <label>Middle Name</label><input type="text" name="mname" value="<?php echo $mname ?>" />
  49. <label>Course</label><input type="text" name="course" value="<?php echo $course ?>" />
  50. <label>Attendance</label><input type="text" name="attendance" value="<?php echo $attendance ?>" />
  51. <label>Exercise</label><input type="text" name="exercise" value="<?php echo $exercise ?>" />
  52. <label>Quiz</label><input type="text" name="quiz" value="<?php echo $quiz ?>" />
  53. <label>Exam</label><input type="text" name="exam"value="<?php echo $exam ?>" />
  54. <label>Final Grade</label><input type="text" name="fg" disabled value="<?php echo $finalGrade ?>" />
  55. <input type="submit" value="Register" name="register" class="btn btn-block btn-primary" />
  56. <button type="button" class="btn btn-block btn-primary"><a href="view.php">View Students </a></button>
  57. </form>
  58. </div>
  59. </div>
  60. </body>
  61. </html>
  62.  
  63.  
  64. ------------------------------------------------------------------------------------------------
  65. view.php // VIEW RECORDS
  66. ------------------------------------------------------------------------------------------------
  67. <?php
  68. include "db/conn.php";
  69.  
  70. ?>
  71. <html>
  72. <head>
  73. </head>
  74. <body>
  75. <div class="container">
  76.  
  77. <table class="table table-striped mt-5 text-center">
  78. <thead class="thead-dark">
  79. <tr>
  80. <th>StudentID</th>
  81. <th>First Name</th>
  82. <th>Last Name</th>
  83. <th>Middle Name</th>
  84. <th>Course</th>
  85. <th>Attendance</th>
  86. <th>Exercise</th>
  87. <th>Quiz</th>
  88. <th>Exam</th>
  89. <th>Final Grade</th>
  90. </tr>
  91. </thead>
  92. <?php
  93. $sql = mysqli_query($conn, "Select * from tbl_info");
  94. while($row = mysqli_fetch_array($sql)){
  95. echo "<tr>";
  96. echo "<td>". $row['studentID']."</td>";
  97. echo "<td>". $row['firstName']."</td>";
  98. echo "<td>". $row['lastName']."</td>";
  99. echo "<td>". $row['middleName']."</td>";
  100. echo "<td>". $row['course']."</td>";
  101. echo "<td>". $row['attendance']."</td>";
  102. echo "<td>". $row['exercise']."</td>";
  103. echo "<td>". $row['quiz']."</td>";
  104. echo "<td>". $row['exam']."</td>";
  105. echo "<td>". $row['finalGrade']."</td>";
  106.  
  107.  
  108. echo "</tr>";
  109.  
  110.  
  111.  
  112.  
  113. }
  114. ?>
  115. </table>
  116. </div>
  117. </body>
  118. </html>
  119.  
  120.  
  121.  
  122. ------------------------------------------------------------------------------------------------
  123. conn.php //CONNECTION
  124. ------------------------------------------------------------------------------------------------
  125. <?php
  126. $server = "localhost";
  127. $username = "root";
  128. $password = "";
  129. $db = "dbmidtermlab";
  130.  
  131. // Create connection
  132. $conn = mysqli_connect($server, $username, $password, $db);
  133.  
  134. // Check connection
  135. if (!$conn) {
  136. die("Connection failed: " . mysqli_connect_error());
  137. }else{
  138.  
  139. }
  140.  
  141. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement