簡體   English   中英

PHP 沒有出現在模態彈出窗口中

[英]PHP for each not showing up in modal popup

使用我的 SQL Select,我讓我的每個表格行都正確顯示在我的 html 表格標簽中,正如您在圖像中看到的那樣。 但是,當我在每一行中單擊我的模態標記時,它只會回顯整個表中的第一行,在本例中為“cat1_tagname CHIROPRACTIC”。 不知道為什么它不基於 for each 回顯,尋找解決方案。

我試圖在模態標簽中添加我的 foreach: <?php foreach($lstTagMain as $rowTagOne) { ?> ,但它會在點擊時顯示每一個。

<?php foreach($lstTagMain as $rowTagOne) { ?>
    <tr class="text-center">
      <td class="col-md-1">
        <a href="category-coupon-list.php?c=1&c1=<?php echo($rowTagOne['product_cat1id']); ?>&c2=0&c3=0&t1=<?php echo($rowTagOne['cat1_tagname']); ?>&t2=0&t3=0"><img src="img/icon-add.png"></a>
      </td>

      <td class="col-md-1">
        <img src="img/icon-edit.png" data-toggle="modal" data-target="#category-edit-one">
        <div id="category-edit-one" class="modal fade" role="dialog">
          <div class="modal-dialog">
              <div class="modal-content address-modal">
                <div class="modal-header">
                  <button type="button" class="close" data-dismiss="modal">&times;</button>
                  <h4 class="modal-title text-center"><?php echo($rowTagOne['cat1_tagname']); ?></h4>
                </div>
                <div class="modal-body">
                  <form method="post" enctype="multipart/form-data">
                    <div class="row">
                        <div class="col-md-12">
                          <input type="text" class="form-control" value="<?php echo($rowTagOne['cat1_tagname']); ?>" name="cat1_tagname" placeholder="Edit Category 1 Name">
                        </div>
                        <div class="col-md-12"><hr></div>

                        <div class="col-md-12">
                          <select class="form-control" name="producttagid" autocomplete="off" required>
                            <?php foreach ($lstTag as $rowTag) { ?>
                              <option class="strong" value="<?php echo $rowTag['producttagid']; ?>"><?php echo $rowTag['tagname']; ?></option>
                            <?php } ?>
                          </select>
                        </div>

                        <div class="col-md-12"><hr></div>

                        <div class="col-md-12">
                          <input type="submit" class="btn button-color-blue font-color-white full_width" name="add_category1" value="ADD">
                        </div>
                    </div>
                  </form>
                </div>
              </div>
          </div>
        </div>
      </td>
     </tr>
  <?php } ?>

SQL 表1

HTML表格2

莫代爾3

問題是你的標記添加和你的每個像<div class="modal-diaogue" I'd="<?php echo($rowTagOne['product_cat1id']); ?>">然后在你的模態上按鈕添加類似<a href="#<?php echo($rowTagOne['product_cat1id']); ?>" open modal</a>的想法是讓每個模態都是獨一無二的,這樣你在打開它時就可以唯一地引用它

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM