gpt4 book ai didi

php - 使用来自 mysql 的信息从 PHP 打开 fancyBox

转载 作者:行者123 更新时间:2023-11-29 23:07:46 25 4
gpt4 key购买 nike

我对这一切都是新手。我仅根据在互联网上找到的内容进行工作。

我有一个图片库([http://adau.ga/peisaje.php])女巫,真正的php显示来自mysql数据库的信息。这是我的 .php 文件脚本:

<html>
<head>
<title>Peisaje</title>
<a href="#portfolio" onclick="galerie()"><h2>Peisaje</h2></a>
</head>
<body>
<br>
<?php
try {
include 'http://adau.ga/conect.php';
$interogare = $cnx->prepare("SELECT * from silvia_poze WHERE id_categorie = 1");
$interogare->execute();
foreach ($interogare->fetchAll() as $linie) {
$img = $linie["poza_mare"];
$id = $linie["id_produs"];
$nume = $linie["titlu"];
echo '<a href="http://adau.ga/element.php?idprod='.$id.' "class=\"buchet_mic\"><img src="images/'.$img.'" height="250" width="250" alt=""/></a>';
}
}
catch(PDOException $e) {
die("Conectare imposibila: " . $e->getMessage());
}
?>
</body>
</html>

这设置为打开一个新的 php 文件 (element.php),其中显示我需要的信息。

现在,我想当点击图片时用 fancyBox 简单画廊打开它。

我已经导入了脚本,如果我只使用html([http://adau.ga/fancy/demo/index.php]),它就可以工作,但我需要fancyBox只显示mysql中具有id_category = 1的数千张图片

最佳答案

我找到了解决方案:

<html>
<head>
<title>Peisaje</title>

<!-- Add jQuery library FANCY BOX GALERIE-->
<script type="text/javascript" src="fancy/lib/jquery-1.10.1.min.js"></script>
<!-- Add mousewheel plugin (this is optional) -->
<script type="text/javascript" src="fancy/lib/jquery.mousewheel-3.0.6.pack.js"></script>
<!-- Add fancyBox main JS and CSS files -->
<script type="text/javascript" src="fancy/source/jquery.fancybox.js?v=2.1.5"></script>
<link rel="stylesheet" type="text/css" href="fancy/source/jquery.fancybox.css?v=2.1.5" media="screen" />

<script type="text/javascript">
$(document).ready(function() {
/* * Simple image gallery. Uses default settings */
$('.fancybox').fancybox();
});
</script>
<style type="text/css">
.fancybox-custom .fancybox-skin {
box-shadow: 0 0 50px #222;
}

body {
margin: 0 auto;
}
</style>

</head>
<body>
<a href="#portfolio" id="portfolio-link" onclick="galerie()"><h2>Peisaje</h2></a>
<br>
<?php
try {
include 'conect.php';
$interogare = $cnx->prepare("SELECT * from silvia_poze WHERE id_categorie = 1");
$interogare->execute();
foreach ($interogare->fetchAll() as $linie) {
$img = $linie["poza_mare"];
$id = $linie["id_produs"];
$nume = $linie["titlu"];
echo '<a class="fancybox" href="/images/'.$img.'" data-fancybox-group="gallery" title="'.$nume.'"><img src="images/'.$img.'" height="150" width="150" alt="" /></a>';
}
}
catch(PDOException $e) {
die("Conectare imposibila: " . $e->getMessage());
}
?>
</body>
</html>

关于php - 使用来自 mysql 的信息从 PHP 打开 fancyBox,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28222125/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com