1

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'/>");    
}
?>
noobie123
  • 13
  • 4

2 Answers2

0

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

Community
  • 1
  • 1
grasshopper
  • 1,381
  • 4
  • 19
  • 36
  • Hi Grasshopper, thank you for your time. I checked the links you attached but they seem rather confusing to me (please excuse me as I don't want be seen as not appreciating your suggestion). How could I make something like an xml file(?) that would include some rules? For example id=123 equals to image01.jpg, id=124 equals to image02.jpg and so on... – noobie123 Nov 21 '12 at 17:28
  • Hello again Grasshopper, thank you very much for your help. I followed your suggested link and managed to do what I needed. For anyone in future who will have the same question can find the answer above in my original question. btw I loved this homeandlearn page. Cheers! – noobie123 Nov 22 '12 at 14:04
0

Okay let me repeat: You have an image. When you click on the image, a javascript will be called, which loads the page, behind the hash, with ajax?

Why not simply add the ?id=123 to the link behind the hash and let PHP return the values from database, depending on given id?

Btw. I strongly recommend, not to execute the load of page 1:1, because this may cause security issues. This looks a bit like XSS.

Armin
  • 15,582
  • 10
  • 47
  • 64
  • Hi Armin, thank you for your reply. The idea of adding ?id=123 is what I'd like to do however I do not know how to define the variables in a database. How do I assign id=123 to image01.jpg for example and then retrieve the data and display it in the left column? Thank you again. – noobie123 Nov 21 '12 at 17:23