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 ETLCloud 处理json多层级问题
  • ¥15 yolov8边框坐标
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真