Acutally, I want to get View List of Result of Student accounting to class. I have written below which i have work on it, but it is showing as figure below.
Database
UserName: admin
Pass: "Test123"
https://drive.google.com/file/d/1vP6wav5mDdfXoJxwjiBRC4wrrBdFWHLj/view?usp=sharing
<html>
<body>
<form method='post' action='view.php'>
Class id: <input type='text' name='classid'>
<input type='submit' name='Register' value='Submit'>
</form>
</body>
</html>
view.html
<?php
if(isset($_POST['Register']))
{
// DB credentials.
$servername = "localhost";
$username = "root";
$password = "";
$DB_NAME = "srms";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $DB_NAME);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
$cid = $_POST['classid'];
$sql = "
select t.StudentName
,t.RollId
,t.ClassId
,t.marks
,SubjectId
,tblsubjects.SubjectName
from (
select sts.StudentName
,sts.RollId
,sts.ClassId
,tr.marks
,SubjectId
from tblstudents as sts
join tblresult as tr
on tr.StudentId = sts.StudentId
) as t
join tblsubjects
on tblsubjects.id = t.SubjectId
where t.ClassId= '".$cid."'" ;
if ($result = $conn->query($sql)) {
$data = $result;
}
}
?>
<html>
<head>
<title>Export MySQL data to Excel in PHP</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
</head>
<body>
<div class="container">
<br />
<br />
<br />
<div class="table-responsive">
<h2 align="center">Result View</h2><br />
<table id="Confirms" border ="2" style="length:900px;width:350px;">
<thead>
<tr style= "background-color: #A4A4A4;">
<td>Roll No.:</td>
<td>Student Name.:</td>
<?php
if ($result = $conn->query($sql)) {
while ($row = $result->fetch_assoc()) {
echo
"<td >{$row['SubjectName']}</td>";
}
}
?>
</tr>
</thead>
<tbody>
<?php
if ($result = $conn->query($sql)) {
while($row = $result->fetch_assoc())
{
echo '
<tr>
<td>'.$row["RollId"].'</td>
<td>'.$row["StudentName"].'</td>
';
}}
?>
<?php
if ($result = $conn->query($sql)) {
while ($row = $result->fetch_assoc()) {
echo
"<td >{$row['marks']}</td>";
}
}
?>
</tr>
</tbody>
</table>
</div>
</div>
</body>
</html>
My output is coming as below figure:
How to get as below figure output: it would great, Please help
Aucun commentaire:
Enregistrer un commentaire