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'];
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度