Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.44 KB | None | 0 0
  1. <?php
  2. if(!empty($_FILES["marks_file"]["name"]))
  3. {
  4. $connect = mysqli_connect("localhost", "root", "", "dbname");
  5. $output = '';
  6. $allowed_ext = array("csv");
  7. $extension = end(explode(".", $_FILES["marks_file"]["name"]));
  8. if(in_array($extension, $allowed_ext))
  9. {
  10. $file_data = fopen($_FILES["marks_file"]["tmp_name"], 'r');
  11. fgetcsv($file_data);
  12. while($row = fgetcsv($file_data))
  13. {
  14. $name = mysqli_real_escape_string($connect, $row[0]);
  15. $Physics = mysqli_real_escape_string($connect, $row[1]);
  16. $Maths = mysqli_real_escape_string($connect, $row[2]);
  17. $Chemistry = mysqli_real_escape_string($connect, $row[3]);
  18. $Biology = mysqli_real_escape_string($connect, $row[4]);
  19. $SST = mysqli_real_escape_string($connect, $row[5]);
  20. $query = "
  21. INSERT INTO csv
  22. (name, Physics, Maths, Chemistry, Biology, SST)
  23. VALUES ('$name', '$Physics', '$Maths', '$Chemistry', '$Biology' , '$SST')
  24. ";
  25. mysqli_query($connect, $query);
  26. }
  27. $select = "SELECT * FROM csv ORDER BY id DESC";
  28. $result = mysqli_query($connect, $select);
  29. $output .= '
  30. <table class="table table-bordered">
  31. <tr>
  32. <th width="25%" >name</th>
  33. <th width="15%" >Physics</th>
  34. <th width="15%" >Maths</th>
  35. <th width="15%" >Chemistry</th>
  36. <th width="15%" >Biology</th>
  37. <th width="15%" >SST</th>
  38. </tr>
  39. ';
  40. while($row = mysqli_fetch_array($result))
  41. {
  42. $output .= '
  43. <tr>
  44. <td>'.$row["name"].'</td>
  45. <td>'.$row["Physics"].'</td>
  46. <td>'.$row["Maths"].'</td>
  47. <td>'.$row["Chemistry"].'</td>
  48. <td>'.$row["Biology"].'</td>
  49. <td>'.$row["SST"].'</td>
  50. </tr>
  51. ';
  52. }
  53. $output .= '</table>';
  54. echo $output;
  55. }
  56. else
  57. {
  58. echo 'errorx';
  59. }
  60. }
  61. else
  62. {
  63. echo "errory";
  64. }
  65. ?>
  66.  
  67. ,,,,,,,,
  68. ,,,,,,,,
  69. ,,,,,,,,
  70. ,,,,,,,,
  71. ,,,,,,,,
  72. ,,,,,,,,
  73. ,,,,,,,,
  74. ,,,,,,,,
  75. ,,,,,,,,
  76. ,,,Fields,Physics~75,Maths~50,Chemistry~65,Bio~85,SST~100
  77. ,,,Name1,10,25,35,42,62
  78. ,,,Name2,80,45,45,45,25
  79. ,,,Name3,63,25,63,36,36
  80. ,,,Name4,82,36,75,48,42
  81. ,,,Name5,45,45,78,25,24
  82. ,,,Name6,36,36,15,75,36
  83. ,,,Name7,99,45,24,24,45
  84. ,,,Name8,45,85,85,85,96
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement