不确定这个语法错误

时间:2018-01-18 14:54:49

标签: php html

我有这个页面,管理员批准/拒绝员工离职。

Leave Details

点击它时,我正试图在status下显示批准/拒绝。我在教程上遵循完全相同的代码,显然我确实有语法错误。错误是“解析错误:语法错误,意外'}'”

这是我的代码:

 <body>
  
<?php 
if(isset($_POST['approved']))
{
  echo "approved";
  $status=$_POST['status']
}
if(isset($_POST['rejected']))
{
  echo "rejected";
  $status=$_POST['status']
}
?>
	
    <!-- Begin page content -->
    <div class="container">
      <div class="page-header">

<h3>
	Employee Leaves
</h3>
			<div class="table-responsive">
				<table class="table">
					<tr>
						<th>Employee Name</th>
						<th>Phone</th>
						<th>Email</th>
						<th>From</th>
						<th>To</th>
						<th>Reason</th>
						<th>Status</th>
						<th>---</th>
					</tr>
				<?php
					include ('database.php');
					$result = $database->prepare ("SELECT * FROM leaves order by id DESC");
					$result ->execute();
					for ($count=0; $row_message = $result ->fetch(); $count++){
				?>
					<tr>
						<td><?php echo $row_message['full_name']; ?></td>
						<td><?php echo $row_message['phone']; ?></td>
						<td><?php echo $row_message['email']; ?></td>
						<td><?php echo $row_message['fromdate']; ?></td>
						<td><?php echo $row_message['todate']; ?></td>
						<td><?php echo $row_message['reason']; ?></td>
						<td><?php echo $row_message['status']; ?></td>
						<td>
						<form method="post" action=""><button type="submit" name="approved">Approve</button></form>
						&nbsp
						<form method="post" action=""><button typ="submit" name="rejected">Reject</button></form>
						</td>
					</tr>
					<?php	}	?>
				</table>
				
				<a href="home"><button type="button" class="btn btn-primary"><i class="glyphicon glyphicon-arrow-left"></i> Back</button></a>
				
			</div>
  </div>

1 个答案:

答案 0 :(得分:0)

在php中,你总是要用一个;来关闭你的行。你忘了添加2;。

 if(isset($_POST['approved']))
 {
  echo "approved";
  $status=$_POST['status'];
}
if(isset($_POST['rejected']))
{
echo "rejected";
$status=$_POST['status'];
}