简体   繁体   English

如何在php中调用bootstrap模式

[英]How to call bootstrap modal in php

I'm trying to call a modal that I have in a html file which is hidden alongside another modal. 我试图在一个隐藏在另一个模态旁边的html文件中调用一个模态。 One of them appears as the button is clicked but the other one is to be called by php as part of a verification process. 其中一个显示为单击按钮,但另一个将由php作为验证过程的一部分调用。

Here is my php code: 这是我的PHP代码:

$File = include("index2.html");
$Msg = 'Welcome ';
$search=$_POST['search'];
$query = $pdo->prepare("SELECT * FROM students WHERE IDs LIKE '%$search%'  LIMIT 0 , 10"); //OR author LIKE '%$search%'
$query->bindValue(1, "%$search%", PDO::PARAM_STR);
$query->execute();
// Display search result
         if (!$query->rowCount() == 0) {
                 echo '<script type="text/javascript">';
                                 echo 'alert("Verification Complete");';
                                  echo '</script>';



            while ($results = $query->fetch()) {

                $Studname = $results['Studentname'];


                echo '<script type="text/javascript">';                
                echo 'alert("'.$Msg.$Studname.'")';
                echo '</script>';



               echo '<script type="text/javascript">';
               echo '$(File).ready(function() {';
               echo '$("#myAdvert").modal("show");';
               echo '});';
               echo '</script>';

            }

         } else {
           echo '<script language="javascript">';
            echo 'alert("Sorry your ID was not found");';
            echo 'window.location.href = "/Koleesy/index.html";';
            echo '</script>';
        }
?>

After the user is welcomed I want the hidden modal from my index.html to be called so the user can continue submitting the advert. 在欢迎用户之后,我希望调用index.html中的隐藏模态,以便用户可以继续提交广告。 I've tried using the include function but that doesn't seem to work in my favor. 我尝试过使用include功能,但这似乎对我不利。 How do I do this? 我该怎么做呢? Every answer is appreciated. 每个答案都表示赞赏。

Try this: 试试这个:

echo "<script type='text/javascript'>
$(document).ready(function(){
$('#myAdvert').modal('show');
});
</script>";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM