Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(!empty($_FILES["marks_file"]["name"]))
- {
- $connect = mysqli_connect("localhost", "root", "", "dbname");
- $output = '';
- $allowed_ext = array("csv");
- $extension = end(explode(".", $_FILES["marks_file"]["name"]));
- if(in_array($extension, $allowed_ext))
- {
- $file_data = fopen($_FILES["marks_file"]["tmp_name"], 'r');
- fgetcsv($file_data);
- while($row = fgetcsv($file_data))
- {
- $name = mysqli_real_escape_string($connect, $row[0]);
- $Physics = mysqli_real_escape_string($connect, $row[1]);
- $Maths = mysqli_real_escape_string($connect, $row[2]);
- $Chemistry = mysqli_real_escape_string($connect, $row[3]);
- $Biology = mysqli_real_escape_string($connect, $row[4]);
- $SST = mysqli_real_escape_string($connect, $row[5]);
- $query = "
- INSERT INTO csv
- (name, Physics, Maths, Chemistry, Biology, SST)
- VALUES ('$name', '$Physics', '$Maths', '$Chemistry', '$Biology' , '$SST')
- ";
- mysqli_query($connect, $query);
- }
- $select = "SELECT * FROM csv ORDER BY id DESC";
- $result = mysqli_query($connect, $select);
- $output .= '
- <table class="table table-bordered">
- <tr>
- <th width="25%" >name</th>
- <th width="15%" >Physics</th>
- <th width="15%" >Maths</th>
- <th width="15%" >Chemistry</th>
- <th width="15%" >Biology</th>
- <th width="15%" >SST</th>
- </tr>
- ';
- while($row = mysqli_fetch_array($result))
- {
- $output .= '
- <tr>
- <td>'.$row["name"].'</td>
- <td>'.$row["Physics"].'</td>
- <td>'.$row["Maths"].'</td>
- <td>'.$row["Chemistry"].'</td>
- <td>'.$row["Biology"].'</td>
- <td>'.$row["SST"].'</td>
- </tr>
- ';
- }
- $output .= '</table>';
- echo $output;
- }
- else
- {
- echo 'errorx';
- }
- }
- else
- {
- echo "errory";
- }
- ?>
- ,,,,,,,,
- ,,,,,,,,
- ,,,,,,,,
- ,,,,,,,,
- ,,,,,,,,
- ,,,,,,,,
- ,,,,,,,,
- ,,,,,,,,
- ,,,,,,,,
- ,,,Fields,Physics~75,Maths~50,Chemistry~65,Bio~85,SST~100
- ,,,Name1,10,25,35,42,62
- ,,,Name2,80,45,45,45,25
- ,,,Name3,63,25,63,36,36
- ,,,Name4,82,36,75,48,42
- ,,,Name5,45,45,78,25,24
- ,,,Name6,36,36,15,75,36
- ,,,Name7,99,45,24,24,45
- ,,,Name8,45,85,85,85,96
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement