Answer the question
In order to leave comments, you need to log in
FancyBox breaks the php. How to decide?
In general, I take data from the MySQL database. I'm trying to display them in a structured way through a loop in php, but at the moments where I use FancyBox, the loop breaks (the variable is always equal to the initial value of the loop). Here is a piece of code:
<?php
for($i=0; $i<3; $i++)
{
echo '
<div class="col-md-4 EinWare">
<h3>'.$all_products[$i]['title'].'</h3>
<a class="Produktbeschreibung" href="#produkte1"><img src="/image/Katalog/'.$all_products[$i]['image'].'" class="Einzug3 imaginator2"></a>
<p>'.$all_products[$i]['description'].'</p>
<p class="price">Цена: '.$all_products[$i]['price'].' рублей</p>
<a class="Produktbeschreibung" href="#produkte1">Подробнее</a>
<form class="variants" action="#">
<input type="submit" class="buy btn btn-custom" value="Купить" data-result-text="Куплено"/>
</form>
</div>
<div style="display: none;">//в этом блоке
<div id="produkte1" class="container-fluid">
<h3>'.$all_products[$i]['title'].$i.'</h3>
<div class="col-md-3">
<img src="/image/Katalog/'.$all_products[$i]['image'].'" class="Einzug3 imaginator2">
</div>
<div class="col-md-6">
<p>'.$all_products[$i]['full_description'].'</p>
</p>
<p>'.$all_products[$i]['description'].'</p>
<p class="price">Цена: '.$all_products[$i]['price'].' рублей</p>
<form class="variants" action="#">
<input type="submit" class="buy btn btn-custom" value="Купить" data-result-text="Куплено"/>
</form>
</div>
</div>
</div>';
}
?>
<a class="Produktbeschreibung" href="#produkte'.$i.'"><img src="/image/Katalog/'.$all_products[$i]['image'].'" class="Einzug3 imaginator2"></a>
...
<a class="Produktbeschreibung" href="#produkte'.$i.'">Подробнее</a>
...
<div id="produkte'.$i.'" class="container-fluid">
Answer the question
In order to leave comments, you need to log in
You have some kind of mess both in your head and in your code.
Fancybox (if you are talking about a library that allows you to "beautifully" enlarge images on a page) does not affect php in any way, because fancybox runs in the browser, and php runs on the server.
And it is better to write the code in such a way that it is easier to read:
<?php for($i=0; $i<3; $i++) { ?>
<div>
...
<?= $all_products[$i]['title'] ?>
...
</div>
<?php } ?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question