php - 单击域名模式应该像弹出窗口一样打开

标签 php mysql model-view-controller yii2

在通知列表中,我使用 SQL 查询来显示域名,但我想要每个域名,当我单击该域名时,将打开包含详细信息的弹出窗口。

这是头文件---

 <!-- notification start -->
        <li class="dropdown">
                      <a href="#" class="dropdown-toggle" data-toggle="dropdown">Notification <b class="caret"></b></a>
                      <ul class="dropdown-menu short-dropdown-menu">

                         <li class=""> <a href="<?=Url::to(['domains/index']);?>">
                    <?php
                    $domains=Domains::find()
                      ->Where('expirydate BETWEEN NOW() AND DATE_ADD(NOW(), INTERVAL 1 MONTH)')
                      ->andWhere(['or',
                                ['status'=> 'Active'],
                                ['status'=> 'Pending Transfer']
                            ])
                      ->orderBy(['expirydate' => SORT_ASC])
                      ->all();                                                                                    
              $domainList=ArrayHelper::map($domains,'id','domainname');
              foreach($domainList as $key => $value)
                     {
                        print '<br>'. $value .'<br>';
                     }
                    ?>       
                     </a></li>                                           
                      </ul>
                    </li>
        <!-- notification ends -->

现在结果是开放的 ---

enter image description here

当点击该域名时,它必须显示弹出窗口,其中包含如下图所示的详细信息-----

enter image description here

更新问题:

<li class="dropdown">
    <a href="#" class="dropdown-toggle" data-toggle="dropdown">Notification <b class="caret"></b></a>
        <ul class="dropdown-menu short-dropdown-menu">
            <li class="">
                <a href="#modal-domaindetails" data-toggle="modal" onclick="getDomainDetails('2696')">

                <?php
                    $domains=Domains::find()
                            ->Where('expirydate BETWEEN NOW() AND DATE_ADD(NOW(), INTERVAL 1 MONTH)')
                            ->andWhere([
                                          'or',
                                          ['status'=> 'Active'],
                                          ['status'=> 'Pending Transfer']
                                      ])
                            ->orderBy(['expirydate' => SORT_ASC])
                            ->all();                        


                    $domainList=ArrayHelper::map($domains,'did','domainname');
                        foreach($domainList as $key => $value) {
                            print '<br>'. $value .'<br>';
                        }
                ?>
                </a>  
            </li>                                           
        </ul>
    </a>
</li>

现在看到这个,我正在传递 id 2696,但我想根据域名获取 id,这怎么可能

最佳答案

我认为,我对此有一些看法。

  1. 如果你想打开一个新的弹出模式,你必须创建一个模式弹出窗口,就像 https://getbootstrap.com/docs/4.1/components/modal/

  2. 您将 URL 重定向到域名设置为“>”,它将被重定向到此链接。您无法在此处弹出任何弹出窗口,除非您想在 chrome 中打开新选项卡或新窗口。(使用打开新标签或新窗口,您可以在谷歌上搜索它)

  3. 在“li”和“a”标签中

    <li class=""> <a href="your_url"> ... your code php foreach($domainList as $key => $value) { print '<br>'. $value .'<br>'; } </a> </li>

你放置一个迭代器,它将呈现一个列表,但它们具有相同的重定向到 URL

更新我的答案

也许我希望它能帮到你。

HTML:

<li class="dropdown">
    <a href="#" class="dropdown-toggle" data-toggle="dropdown">Notification <b class="caret"></b></a>
        <ul class="dropdown-menu short-dropdown-menu">
            <li class="">

                <?php
                    $domains=Domains::find()
                            ->Where('expirydate BETWEEN NOW() AND DATE_ADD(NOW(), INTERVAL 1 MONTH)')
                            ->andWhere([
                                          'or',
                                          ['status'=> 'Active'],
                                          ['status'=> 'Pending Transfer']
                                      ])
                            ->orderBy(['expirydate' => SORT_ASC])
                            ->all();                        


                    $domainList=ArrayHelper::map($domains,'did','domainname');
                        foreach($domainList as $key => $value) {
                ?>
                <a href="javascript:;" onclick="getDomainDetails('<?= $key ?>')"><?= $value ?></a>
                <?php
                        }
                ?>

            </li>                                           
        </ul>
    </a>
</li>

添加了模态弹出窗口

<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <div class="modal-body">

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                </div>
        </div>
    </div>
</div>

JavaScript

<script>

    function getDomainDetails(domain_id) {
        $.ajax({
            url: 'domains/index',
            method: 'GET', // or 'POST'
            data: { domain_id : domain_id }
        })
        .done(function(response) {
            $('#exampleModal').find('.modal-body').html(response); // append reponse html from server
            $('#exampleModal').modal('show'); // show modal
        });
    }


</script>

关于php - 单击域名模式应该像弹出窗口一样打开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51645826/

相关文章:

Java SE框架和架构?

delphi - 如何使用dunit的DUnitWizard中包含的XPObserver单元来实现观察者模式,甚至MVC模式?

c# - SignalR 安全消息传递

php - Mysql添加重复的varchar

php - 每个卖家的邮政编码过滤器 - mysql

javascript - 将项目添加到表格模板的 Handlebars

php - 使用PHP从MYSQL中的一对多关系获取嵌套的JSON数据

php - 如何在 PHP 中创建动态 MySQL 更新查询

php - MySql,如何从不同用户获取最后一条消息

mysql - 如何在Mysql中设置NULL文本字段