如何在php中调用引导模式

How to call bootstrap modal in php

本文关键字:模式 调用 php      更新时间:2023-09-26

我正试图调用一个隐藏在另一个模态旁边的html文件中的模态。其中一个在单击按钮时出现,但另一个将由php调用,作为验证过程的一部分。

这是我的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>';
        }
?>

在欢迎用户之后,我希望从我的index.html中调用隐藏的模态,这样用户就可以继续提交广告。我试过使用include函数,但似乎对我不利。我该怎么做?感谢您的每一个回答。

试试这个:

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