如何解决当我尝试将结果下载为 PDF 文件时,它在 php 中出现白色且清晰的屏幕
当我尝试将结果下载为 PDF 文件时,当我将此 projext 上传到真实服务器时,它会显示白色且清晰的屏幕,但该项目在我的 PC 上由本地服务器 100% 运行。但是,我检查了与服务器连接的页面,一切都很好。
结果页 result.php
<?php
session_start();
error_reporting(0);
include('includes/config.php');
?>
<!DOCTYPE html>
<html lang="tr">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Sonuç Yönetim Sistemi</title>
<link rel="stylesheet" href="css/bootstrap.min.css" media="screen" >
<link rel="stylesheet" href="css/font-awesome.min.css" media="screen" >
<link rel="stylesheet" href="css/animate-css/animate.min.css" media="screen" >
<link rel="stylesheet" href="css/lobipanel/lobipanel.min.css" media="screen" >
<link rel="stylesheet" href="css/prism/prism.css" media="screen" >
<link rel="stylesheet" href="css/main.css" media="screen" >
<script src="js/modernizr/modernizr.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6" crossorigin="anonymous">
</head>
<body>
<div class="main-wrapper">
<div class="content-wrapper">
<div class="content-container">
<!-- /.left-sidebar -->
<div class="main-page">
<div class="container-fluid">
<div class="row page-title-div">
<div class="col-md-12">
<h2 class="title" align="center">Sonuç Yönetim Sistemi</h2>
</div>
</div>
<br>
<!-- /.row -->
<!-- /.row -->
</div>
<!-- /.container-fluid -->
<section class="section">
<div class="container-fluid">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="panel">
<div class="panel-heading">
<div class="panel-title">
<?php
// code Student Data
$rollid=$_POST['rollid'];
$classid=$_POST['class'];
$_SESSION['rollid']=$rollid;
$_SESSION['classid']=$classid;
$query = "select tblstudents.StudentName,tblstudents.RollId,tblstudents.RegDate,tblstudents.StudentId,tblstudents.Status,tblclasses.ClassName,tblclasses.Section from tblstudents join tblclasses on tblclasses.id=tblstudents.ClassId where tblstudents.RollId=:rollid and tblstudents.ClassId=:classid ";
$stmt = $dbh->prepare($query);
$stmt->bindParam(':rollid',$rollid,PDO::PARAM_STR);
$stmt->bindParam(':classid',$classid,PDO::PARAM_STR);
$stmt->execute();
$resultss=$stmt->fetchAll(PDO::FETCH_OBJ);
$cnt=1;
if($stmt->rowCount() > 0)
{
foreach($resultss as $row)
{ ?>
<div class="d-flex">
<div class="flex-shrink-0">
<img src="images/res_profile.jpg" alt="..." style="width: 100px;height: 100px;">
</div>
<div class="flex-grow-1 ms-3">
<h3><?php echo htmlentities($row->StudentName);?></h3> <br>
T.C. : <b><?php echo htmlentities($row->RollId);?></b>
| Sınıf: <b><?php echo htmlentities($row->ClassName);?>(<?php echo htmlentities($row->Section);?>) </b>
</div>
</div>
<?php }
?>
</div>
<br>
<div class="panel-body p-20">
<table class="table table-hover table-bordered">
<thead>
<tr>
<th>#</th>
<th>Konu</th>
<th>Puan</th>
</tr>
</thead>
<tbody>
<?php
// Code for result
$query ="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.RollId=:rollid and t.ClassId=:classid)";
$query= $dbh -> prepare($query);
$query->bindParam(':rollid',PDO::PARAM_STR);
$query->bindParam(':classid',PDO::PARAM_STR);
$query-> execute();
$results = $query -> fetchAll(PDO::FETCH_OBJ);
$cnt=1;
if($countrow=$query->rowCount()>0)
{
foreach($results as $result){
?>
<tr>
<th scope="row"><?php echo htmlentities($cnt);?></th>
<td><?php echo htmlentities($result->SubjectName);?></td>
<td><?php echo htmlentities($totalmarks=$result->marks);?></td>
</tr>
<?php
$totlcount+=$totalmarks;
$cnt++;}
?>
<tr>
<th scope="row" colspan="2">Toplam puan</th>
<td><b><?php echo htmlentities($outof=($cnt-1)*100); ?></b> üzerinden <b><?php echo htmlentities($totlcount); ?></b></td>
</tr>
<tr>
</tr>
<tr>
<th scope="row" colspan="2">Sonucu Yazdır</th>
<td><b><a href="download-result.php"><b> Yazdır </b> </a></b></td>
</tr>
<?php } else { ?>
<div class="alert alert-warning left-icon-alert" role="alert">
<strong>Not!</strong> Sonucunuz henüz sisteme yüklenmedi
<?php }
?>
</div>
<?php
} else
{?>
<div class="alert alert-danger left-icon-alert" role="alert">
strong>Oh snap!</strong>
<?php
echo htmlentities("geçersiz kimlik");
}
?>
</div>
</tbody>
</table>
<div class="alert alert-primary" role="alert">
<center><h1>Yüzde Puanı: <b><?php echo htmlentities($totlcount*(100)/$outof); ?>%</b></h1></center></div>
<div class="clearfix">
<div class="float-start" style="margin: 10px;">
<center><p><h5> Rector imzasi</h5></p>
<p><h4>Adam Süleyman</h4></p>
<p><img style="margin-top: -30px;" height="100px" width="200px" src="https://upload.wikimedia.org/wikipedia/commons/a/ac/Chris_Hemsworth_Signature.png"></p> </center>
</div>
<div class="float-end" style="margin: 10px;">
<center><p><h5> Rector imzasi</h5></p>
<p><h4>Kader Karadeniz</h4></p>
<p><img style="margin-top: -30px;" height="100px" width="200px" src="https://upload.wikimedia.org/wikipedia/commons/3/3a/Jon_Kirsch%27s_Signature.png"></p> </center>
</div>
</div>
</div>
</div>
<!-- /.panel -->
</div>
<!-- /.col-md-6 -->
<div class="form-group">
<div class="col-sm-6">
<a href="index.php">Anasayfa'ya</a>
</div>
</div>
</div>
<!-- /.row -->
</div>
<!-- /.container-fluid -->
</section>
<!-- /.section -->
</div>
<!-- /.main-page -->
</div>
<!-- /.content-container -->
</div>
<!-- /.content-wrapper -->
</div>
<!-- /.main-wrapper -->
<!-- ========== COMMON JS FILES ========== -->
<script src="js/jquery/jquery-2.2.4.min.js"></script>
<script src="js/bootstrap/bootstrap.min.js"></script>
<script src="js/pace/pace.min.js"></script>
<script src="js/lobipanel/lobipanel.min.js"></script>
<script src="js/iscroll/iscroll.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/js/bootstrap.bundle.min.js" integrity="sha384-JEW9xMcG8R+pH31jmWH6WWP0WintQrMb4s7ZOdauHnUtxwoG2vI5DkLtS3qm9Ekf" crossorigin="anonymous"></script>
<!-- ========== PAGE JS FILES ========== -->
<script src="js/prism/prism.js"></script>
<!-- ========== THEME JS ========== -->
<script src="js/main.js"></script>
<script>
$(function($) {
});
</script>
<!-- ========== ADD custom.js FILE BELOW WITH YOUR CHANGES ========== -->
</body>
</html>
将结果下载为 PDF 页面download-result.php
<?php
namespace Dompdf;
require_once ("dompdf/autoload.inc.php");
session_start();
ob_start();
require_once("includes/configpdo.php");
error_reporting(0);
?>
<html>
<style>
body {
padding: 4px;
text-align: center;
}
table {
width: 100%;
margin: 10px auto;
table-layout: auto;
}
.fixed {
table-layout: fixed;
}
table,td,th {
border-collapse: collapse;
}
th,td {
padding: 1px;
border: solid 1px;
text-align: center;
}
</style>
<body>
<?php $rollid=$_SESSION['rollid'];
$classid=$_SESSION['classid'];
$query = "SELECT tblstudents.StudentName,tblclasses.Section from tblstudents join tblclasses on tblclasses.id=tblstudents.ClassId where tblstudents.RollId=? and tblstudents.ClassId=?";
$stmt21 = $mysqli->prepare($query);
$stmt21->bind_param("ss",$classid);
$stmt21->execute();
$res1=$stmt21->get_result();
$cnt=1;
while($result=$res1->fetch_object())
{ ?>
<p><b>Student Name :</b> <?php echo htmlentities($result->StudentName);?></p>
<p><b>Student Roll Id :</b> <?php echo htmlentities($result->RollId);?>
<p><b>Student Class:</b> <?php echo htmlentities($result->ClassName);?>(<?php echo htmlentities($result->Section);?>)
<?php }
?>
<table class="table table-inverse" border="1">
<table class="table table-hover table-bordered">
<thead>
<tr>
<th>#</th>
<th>Konu</th>
<th>Puanlar</th>
</tr>
</thead>
<tbody>
<?php
// Code for result
$query ="SELECT t.StudentName,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.RollId=? and t.ClassId=?)";
$stmt = $mysqli->prepare($query);
$stmt->bind_param("ss",$classid);
$stmt->execute();
$res=$stmt->get_result();
$cnt=1;
while($row=$res->fetch_object())
{
?>
<tr>
<td ><?php echo htmlentities($cnt);?></td>
<td><?php echo htmlentities($row->SubjectName);?></td>
<td><?php echo htmlentities($totalmarks=$row->marks);?></td>
</tr>
<?php
$totlcount+=$totalmarks;
$cnt++;}
?>
<tr>
<th scope="row" colspan="2">Toplam puan</th>
<td><b><?php echo htmlentities($totlcount); ?></b> out of <b><?php echo htmlentities($outof=($cnt-1)*100); ?></b></td>
</tr>
<tr>
<th scope="row" colspan="2">Yüzde</th>
<td><b><?php echo htmlentities($totlcount*(100)/$outof); ?> %</b></td>
</tr>
</tbody>
</table>
</div>
</body></html>
<?php
$html = ob_get_clean();
$dompdf = new DOMPDF();
$dompdf->setPaper("A4","landscape");
$dompdf->load_html($html);
$dompdf->render();
//dompdf->stream("",array("Attachment" => false));
$dompdf->stream("sonuc.pdf");
?>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。