我想在 php 中显示我的 html 页面的主体,即条件为真或假 [即我使用 if,else 条件]...
<?php
session_start();
if(isset($_SESSION['user']))
{
echo ". Hello ".$_SESSION['user']." !";
}
else
{
header("Location: login.php");
}
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="mystyle.css">
<link href="slims.css" rel="stylesheet" type="text/css">
<title>Enter Attendance</title>
</head>
<body >
<a id="logout" href="logout.php">Logout </a>
<div id="wrapper">
<header>
<h1>Welcome to SLIMS</h1>
<nav id="mainnav">
<ul>
<li><a href="index.php">Home</a></li>
<li><a href="secselect.php" class="thispage">
attendance</a></li>
<li><a href="#">marks</a></li>
<li><a href="#">results</a></li>
<li><a href="#">others</a></li>
</ul>
</nav></header>
<div id=body>
<br/>
<?php
$num=1;
mysql_connect("localhost","root","");
mysql_select_db("attendance");
$_SESSION['tablename']=$_GET['dept']."-".$_GET['year']."-".$_GET['sec']."-".$_GET['sem'];
//echo $_SESSION['tablename'];
$_SESSION['subject']=$_GET['subject'];
$_SESSION['datepicker']=$_GET['datepicker'];
$qstr2="select * from `".$_SESSION['tablename']."-total` where date='".$_GET['datepicker']."' and subject='".$_GET['subject']."';";
//echo $qstr2;
$check=mysql_query($qstr2);
if($check)
{ echo "<font color='white' align=center face='Lucida Sans Unicode'><h2 class='centered'>Attendence for the selected date was already entered</h2></font><br><br><br><br>";
}
else
{
$qstr="select * from `".$_SESSION['tablename']."`;";
$result=mysql_query($qstr);
if(!$result)
{
echo "Invalid details selected";
}
else
{
echo '<font color="white" align=center face="Lucida Sans Unicode"><h2>Enter Attendance</h2></font>
<form method="post" action="insertatt.php" ><p align="center">
<table id="box-table-a"; >
<thead>
<tr>
<th scope="col"> Sl.No </th>
<th scope="col"> JNTU No. </th>
<th scope="col"> Name </th>
<th scope="col"> Classes </th>
</tr>
</thead>
<tbody>';
$num=1;
while($row=mysql_fetch_array($result))
{
echo "<tr><td>".$row['Sl.No']."</td>
<td>".$row["JNTU No"]."</td>
<td>".$row["Name"]."</td>
<td> <input type='radio' name='rbtn".$num."' value=1 /> 1
<input type='radio' name='rbtn".$num."' value=2 /> 2</td>
</tr>";
$num=$num+1;
}
echo "
</tbody>
</table>
<input type='submit' name='submit' value='Post Attendance' />
<input type='reset' name='reset' value='Clear Form' /></p><br><br>
</form>";
}
}?>
</div>
<footer><div id="footer">© 2013 Team 17</div>
</footer>
</div>
</body>
</html>
我需要通过在html标签内的许多地方将“to”和“to”转换为“来做很多修改,以使echo
语句的语法正确......有没有更好的方法来做到这一点??