gpt4 book ai didi

php - 使用 php jquery ajax 从 mysql 获取图像并将它们显示在 DIV 内的 html 页面中

转载 作者:可可西里 更新时间:2023-11-01 07:23:33 24 4
gpt4 key购买 nike

在深入搜索我的问题后我正在编辑我的问题基本上我的网站是一个时尚展示网站它显示鞋布和包包等现在很明显我会有很多照片我正在用 jquery 和 javascript 解决我的问题当用户单击索引页上的缩略图或他转到菜单并单击鞋子链接时,javascript 在新选项卡中打开较大的图像,但现在我正在切换到 php,我在下面做了什么

  1. 我创建了一个 mysql 数据库,其中包含图像的路径,例如用于缩略图的 images/zara/thumbnails/shoes 和用于较大图像的 images/zara/shoes

  2. 当用户点击 ex(shoes) 的链接时,jquery 会像这样抓取链接文本

       $(document).ready(function() {
    $('ul.sub_menu a').click(function() {
    var txt = $(this).text();
    $.ajax({
    type: 'POST',
    url: 'thegamer.php',
    data: {'txt'}
    });
    });
    });

现在进一步将它传递给 php 文件,我现在面临一个问题,我现在需要的是

that how will php make search on the basis of that var txt in the database retrieve the thumbnails of the shoes open a new tab say(shoes.html) and display all the available shoes thuumbnails in divs

最佳答案

这是应该工作的 jquery 代码:

<script>
$(function () {

$(document).on('click', 'div.prodcls img', function (e) {
e.preventDefault();
window.open($(this).attr('src').replace('/thumbnails', ''), '');
});

});
</script>

还有一些CSS:

<style>
div.prodcls img:hover {
cursor: pointer;
}
</style>

这是一个工作 fiddle :http://jsfiddle.net/DenGp/

关于php - 使用 php jquery ajax 从 mysql 获取图像并将它们显示在 DIV 内的 html 页面中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8600027/

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