-2

我想将 ID 值传递给 POPUP DIV 并更新为带有状态的表,带有 ID 的建议文本区域。

如果我这样href="#pop1?id=<?php echo $row['id']; ?> 通过 POPUP div 未打开。所以我不知道如何通过,所以有人告诉我如何通过 PHP 或 Javascript

提前致谢

                <div class="widget-content">
                    <table class="table table-bordered table-striped data-table">
                    <thead>
                        <tr>
                            <th>S.No</th>
                            <th>Employee Name</th>
                            <th>Reason</th>
                            <th>Category</th>
                            <th>From</th>
                            <th>To</th>
                            <th>No Of Days</th>
                            <th>Action</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php
                        $result=mysql_query("select * from leave_request");
                        while($row=mysql_fetch_array($result))

                        {?>
                        <tr>
                            <td><?php echo $row['id'];?></td>
                            <td> <?php echo $row['emp_name'];?></td>
                            <td> <?php echo $row['reason'];?></td>
                            <td> <?php echo $row['category'];?></td>
                            <td><?php echo $row['from_date'];?></td>
                            <td><?php echo $row['to_date'];?></td>
                            <td><?php echo $row['no_of_days'];?></td>
                            <td>
                            <a href="leave_dashboard.php?id=<?php echo $row['id']; ?>&status='1'" style="text-decoration:none;">Accept </a> |
                            <a href="leave_dashboard.php?id=<?php echo $row['id']; ?>&status='2'"> Reject </a>|
                            <a href="#pop1?id=<?php echo $row['id']; ?>"> Suggest</a> </td>
                              <div id="pop1" class="pop-up">
                              <?php $suggest_id = $_GET['id']; ?>
                                <div class="popBox">
                                  <div class="popScroll">
                                        <form>
                                            <textarea name="suggest" id="suggest" cols="60" rows="8" ></textarea>
                                            <input type="text" name="id" value="<?php echo $suggest_id; ?>">
                                            <input type="text" name="status" value="3">
                                            <button type="submit" name="submit"   class="btn btn-primary">Submit</button>
                                        </form>
                                        <!-- popup content end here -->
                                  </div>
                                  <a href="#links" class="close"><span>Back to links</span></a>
                                </div>
                                <a href="#links" class="lightbox">Back to links</a>
                              </div>
                           </tr>
                        <?php }?>
                    </tbody>
                </table>    
                </div>
4

1 回答 1

0

正如我所见,您的弹出 div 处于 WHILE 循环中,因此您可以像这样获取您的 id:-

初始化一个值说K = 1;并将这个值放到每个弹出窗口中

<a href="#pop<?php echo $k; ?>"> Suggest</a>

完整代码:-

    <?php
    $result=mysql_query("select * from leave_request");
    while($row=mysql_fetch_array($result))    
    {
        $k =1;

    ?>
        <tr>
        <td><?php echo $row['id'];?></td>
        <td> <?php echo $row['emp_name'];?></td>
        <td> <?php echo $row['reason'];?></td>
        <td> <?php echo $row['category'];?></td>
        <td><?php echo $row['from_date'];?></td>
        <td><?php echo $row['to_date'];?></td>
        <td><?php echo $row['no_of_days'];?></td>
        <td>
        <a href="leave_dashboard.php?id=<?php echo $row['id']; ?>&status='1'" style="text-decoration:none;">Accept </a> |
        <a href="leave_dashboard.php?id=<?php echo $row['id']; ?>&status='2'"> Reject </a>|
        <a href="#pop<?php echo $k; ?>"> Suggest</a> </td>



        <div id="pop<?php echo $k; ?>" class="pop-up">

        <div class="popBox">
        <div class="popScroll">
        <form>
           <textarea name="suggest" id="suggest" cols="60" rows="8" ></textarea>
           <input type="text" name="id" value="<?php echo $row['id']">
           <input type="text" name="status" value="3">
          <button type="submit" name="submit"   class="btn btn-primary">Submit</button>
         </form>
           <!-- popup content end here -->
      </div>
          <a href="#links" class="close"><span>Back to links</span></a>
          </div>
          <a href="#links" class="lightbox">Back to links</a>
          </div>
    </tr>
  <?php 

       $k++;

  }?>
于 2013-10-26T07:10:39.130 回答