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

标签 php jquery mysql html ajax

在深入搜索我的问题后我正在编辑我的问题基本上我的网站是一个时尚展示网站它显示鞋布和包包等现在很明显我会有很多照片我正在用 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/

相关文章:

MySQL 触发器不工作

javascript - Html 表格转 PDF 我想对其进行格式化(页码,第二页不好)

javascript - 使用JQuery发送表单数据并解析返回的JSON数据

php - 如何在 laravel 验证后修改请求输入?

jquery - 如何在 jquery 的 .html() 中执行 jquery/javascript 代码

javascript - 当 jquery 将附加 html 获取到页面时显示加载图标

android - 在 Bootstrap 响应式 View 中只有图片链接的一 Angular 是可点击的

php - 使用oauth php第二次自动登录twitter

php - 将所有子数组合并为一个

php - 如何在 facebook 等 Web 应用程序中实现线程消息