I'm trying to call a modal that I have in a html file which is hidden alongside another modal. 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.
Here is my php code:
$File = include("index2.html");
$Msg = 'Wele ';
$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 weled I want the hidden modal from my index.html to be called so the user can continue submitting the advert. I've tried using the include function but that doesn't seem to work in my favor. How do I do this? Every answer is appreciated.
I'm trying to call a modal that I have in a html file which is hidden alongside another modal. 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.
Here is my php code:
$File = include("index2.html");
$Msg = 'Wele ';
$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 weled I want the hidden modal from my index.html to be called so the user can continue submitting the advert. I've tried using the include function but that doesn't seem to work in my favor. How do I do this? Every answer is appreciated.
Share Improve this question asked Oct 28, 2015 at 11:14 KamandaKamanda 3053 gold badges5 silver badges11 bronze badges 4- Where is your modal box defined? – Happy Coding Commented Oct 28, 2015 at 11:17
- It's in my main index file, on the home page. I named that index2 because the php couldn't find the main one so I duplicated it and threw the index2 into the folder with the php. – Kamanda Commented Oct 28, 2015 at 11:20
- Just a suggestion, instead of writing lots of echo statements you can do something like <?php if(true){?> <div>your html code goes here</div> <?php } ?> this would make your code more readable. – Arpita Commented Oct 28, 2015 at 11:57
- Thanks for the advice, i'll definitely use that. Its quite messy with all the echos – Kamanda Commented Oct 28, 2015 at 12:02
1 Answer
Reset to default 6Try this:
echo "<script type='text/javascript'>
$(document).ready(function(){
$('#myAdvert').modal('show');
});
</script>";