douliaodun9153 2018-01-18 14:54
浏览 34
已采纳

不确定这个语法错误[重复]

This question already has an answer here:

I have this page where the administrator approves/rejects employee leaves.

Leave Details

I'm trying to make approve/reject show up under status when I click on it. I followed the exact same code on the tutorial, apparently I do have a syntax error. The error was "Parse error: syntax error, unexpected '}'"

Here's my code:

 <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>

</div>
  • 写回答

1条回答 默认 最新

  • doutun1362 2018-01-18 14:56
    关注

    In php you always have to close off your lines with a ;. You forgot to add 2 ;.

     if(isset($_POST['approved']))
     {
      echo "approved";
      $status=$_POST['status'];
    }
    if(isset($_POST['rejected']))
    {
    echo "rejected";
    $status=$_POST['status'];
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何使用simulink建立一个永磁同步直线电机模型?
  • ¥30 天体光谱图的的绘制并得到星表
  • ¥15 PointNet++的onnx模型只能使用一次
  • ¥20 西南科技大学数字信号处理
  • ¥15 有两个非常“自以为是”烦人的问题急期待大家解决!
  • ¥30 STM32 INMP441无法读取数据
  • ¥15 R语言绘制密度图,一个密度曲线内fill不同颜色如何实现
  • ¥100 求汇川机器人IRCB300控制器和示教器同版本升级固件文件升级包
  • ¥15 用visualstudio2022创建vue项目后无法启动
  • ¥15 x趋于0时tanx-sinx极限可以拆开算吗