添加一些PHP代码后,下面的代码将被删除。如果我删除PHP部分,那么它工作正常。即使在源代码中,以下HTML代码也不显示
<div class="row data">
<div class="row info">
<div class="datatitle">Education</div>
</div>
<div class="grad-fetch row">
<?php
session_start();
$hostname = "127.0.0.1";
$username = "root";
$db_password = "";
$db_name = "resume";
$conn = mysqli_connect($hostname, $username, $db_password, $db_name);
if(!$conn){
die("connection failed : ".mysqli_connect_error());
}
/* $sql = graduation(degree_status ,college ,start_year ,end_year ,degree ,stream ,performence_scale ,performence_marks)*/
$sql = 'SELECT * FROM graduation ';
$result = mysqli_query($conn, $sql);
if (!$result) {
die("Error: " . $sql . "<br>" . mysqli_error($conn));
}
while ($row=mysqli_fetch_array($result)) {
$deg= $row['degree'];
$str= $row['stream'];
$str_yr= $row['start_year'];
$end_yr= $row['end_year'];
$clg= $row['college'];
$prf_scl= $row['performence_scale'];
$prf_mrk= $row['performence_marks'];
}
?>
</div class="row">
<h5>
<?php
echo $deg;
echo $str;
echo $str_yr;
echo $end_yr;
?>
</h5>
<div>
<?php
echo $clg;
?>
</div>
<div>
<?php
echo $prf_scl;
echo $prf_mrk;
?>
</div>
<div>
<?php
exit;
mysqli_close($conn);
?>
</div>
<div class="row dialouge"><h4>Tell us bit about your education</h4></div>
<div class="col userinfo">
<div class="row discipline" data-toggle="modal" data-target="#graduation-modal" id="grad">Graduation
<i class="fa fa-plus education-fa-plus fa-x" aria-hidden="true"></i>
</div>
<div class="row discipline" data-toggle="modal" data-target="#hs-modal">XII(Higer Secondary)
<i class="fa fa-plus education-fa-plus fa-x" aria-hidden="true"></i>
</div>
<div class="button-container">
<a href="student.php" class="previous">PREVIOUS</a>
</div>
</div>
如果我不添加PHP代码,则所有内容均会显示,但添加以下部分后,则不会显示。我不明白这里出了什么问题
答案 0 :(得分:4)
<?php
exit;
mysqli_close($conn);
?>
您需要从代码中删除退出,因为它将在此处停止执行。