dscojuxf69080 2012-11-21 16:55
浏览 120
已采纳

动态地将图像从URL加载到div中

So,

basically I have this image gallery > http://sensemillia.com/#/pages/necklaces.php once the user clicks on one of them images he's lead to the item.php > http://sensemillia.com/#/pages/item.php

As you can see on the left side of the box, there is an image and on the right, there's text.

What I'd like to do, is tell to dynamically item.php load the content depending the url.

Moreover, if the user for example clicks on the first image in the gallery, the url should look like this > ...item.php?id=01 and then accordingly the content of the box should load image01.jpg on the left column, and div01 on the right.

I've searched a lot for this, but all I find are complicated asp or .net answers. Is there a simple way?

Thank you very much in advance. Any help would be greatly appreciated.


ANSWER

<?php $actual_link = "$_SERVER[REQUEST_URI]"; 
if ($actual_link == "/pages/item.php?id=11") {
print ("<img src='../Sensemillia/sousou.jpg' id='jack' width='392' 
height='475' alt='Daisy on the Ohoopee'/>");    
}
else if ($actual_link == '/pages/item.php?id=12') {
print ("<img src='../Sensemillia/second.jpg' id='jack' width='392'
height='475' alt='Daisy on the Ohoopee'/>");    
}
?>
  • 写回答

2条回答 默认 最新

  • douhui8454 2012-11-21 16:59
    关注

    You can use session variables or use POST to send data between the pages and fetch the data from your database

    How do I pass data between pages in PHP?

    PHP Pass variable to next page

    Edit: Maybe you'll want to start here: http://www.homeandlearn.co.uk/php/php.html

    It will give you basic understanding of php and allow you implement that feature on your site.

    Also when you're comfortable with mysql queries you'll want to replace them with PDO

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100