Answer the question
In order to leave comments, you need to log in
How to correctly load get data into a modal window?
I need to load statistical pages from mysql into a pop-up window, there is a ready-made version with a get request ?mod=page&id=test in index.php there is this code
$page = 'main';
if (!empty($_GET['mod']) && $mod = $_GET['mod']) {
$modFile = LD_ROOT_DIR . '/pages/' . $mod . '.php';
if (file_exists($modFile)) {
$page = $mod;
}
}
if (empty($_GET['id'])) {
MessageSend(1, 'Страница не найдена!', '/');
}
$page = $link->prepare("SELECT * FROM `pages` WHERE `name` = ? LIMIT 1");
if (!$page->execute([ $_GET['id'] ])) {
MessageSend(1, 'Ошибка БД!', '/');
}
if ($page->rowCount() <= 0) {
MessageSend(1, 'Страница не найдена!', '/');
}
$page = $page->fetch();
if ($page['adv'] == 0) {
$pageData['hideAdvert'] = false;
}
echo loadTpl('/pages/page/main.html', $page);
<div class="modal fade bd-example-modal-lg" tabindex="-<?=$data['id'];?>" id="modal_<?=$data['name'];?>">
<div class="modal-dialog">
<div class="container">
<div class="row align-items-center justify-content-center">
<div class="col-12 col-lg-10">
<div class="modal-content contacts_modal" id="result">
<button type="button" class="close" data-dismiss="modal">
<img src="/style/img/close.svg">
</button>
<div class="row justify-content-center">
<div class="col-11 col-lg-10">
<h1><?php echo $data['title']; ?></h1>
<div class="steps row">
<div class="col-12 col-lg-12">
<div class="step">
<?php echo $data['text']; ?>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
/?mod=page&id=343r
and follow the link of the modal window<a href="#modal_343r" data-toggle="modal">Контакты</a>
all the information of the page I need is displayed, but if you go to the main page, then follow the link indicated above, the window does not open, naturally, the information itself, what could be the problem, tell me?
Answer the question
In order to leave comments, you need to log in
On your main page, after all, there is no call (execution) of the page.php file with the data $_GET['id']="343r"; ? Therefore, the HTML of the modal window is not generated, this HTML is not displayed anywhere, and this HTML simply does not exist on the main page .
Verdict: therefore, the modal window with this HTML on the main page will show - NOT-WHO-POSSIBLE-BUT , no matter how many times you click on the "Contacts" link...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question