0

Im writing a gallery application in php that reads Facebook album data and creates individual photo albums. The main php file contains an array of albums which it uses to create a list the viewer can select from to open a specific album. What i want to do is keep the array central to a single file and have it create a separate page for each album.

the array is as follows

$albumList = array(
array(
    network => "facebook",
    path    => "393991930641111"
    cover   => "images/sculpture.png" 
),
array(
    network => "facebook" ,
    path    => "183578065022222"
            cover   => "images/photography.png"     
)
    //more array entries for each new album
)

the main PHP file uses this array to create a list, which you can click on to open each individual album.

I dont want to have to create a new php file every single time i want to add a gallery to the array.

Is there a way i can have the list created from the array use links like mysite.com/gallery/index.php&id=0 and this would load a unique page being functionally the same as a separate file itself? (it would just call a function passing the id to load the gallery/content it needs).

Gazow
  • 1,019
  • 2
  • 11
  • 16

1 Answers1

1

There are many ways to do what you're asking. One way is to use $_GET request. Just create a page called gallery.php and insert this at the top:

$albumListArray = $_GET['list-id']; 

You need the pass the id into the URL and it will look something like this:

yoursite.com/gallery.php?list-id=

Here is a resource for you to learn more: PHP Pass variable to next page

Community
  • 1
  • 1
MrPizzaFace
  • 7,807
  • 15
  • 79
  • 123