【发布时间】:2016-01-28 03:17:32
【问题描述】:
我正在尝试调用隐藏在另一个模态旁边的 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 函数,但这似乎对我不利。 我该怎么做呢? 每一个答案都值得赞赏。
【问题讨论】:
-
你的模态框是在哪里定义的?
-
它在我的主索引文件中,在主页上。我将那个 index2 命名为 php 找不到主要的,所以我复制了它并将 index2 与 php 一起放入文件夹中。
-
只是一个建议,而不是编写大量的 echo 语句,您可以执行类似你的 html 代码在这里这将使您的代码更具可读性。
-
感谢您的建议,我一定会使用的。所有的回声都很混乱
标签: javascript php jquery html twitter-bootstrap