Is it possible to have a "php if" statement within a "php if" statement? I don't know a whole lot about php, so I'm sorry if I use the wrong terms to describe things here. I'll try to be as specific as possible.
The website is for an art gallery that has multiple artists. I want to have a page for each artist that show samples of their work. This samples page will display small images in a table. The table will have a max of 3 images per column with a varying number of rows, depending on how many works of art each artist has.
I have designed it such that there is a sort of template page called artist_page.php. Then each artist has a php page that only contains variables in the code, such as a $image_1, $image_2, $image_3, etc. So let's say we are displaying works by Leonardo da Vinci. There would be a davinci.php page and the first variable would be $image_1="Mona_Lisa". On the page that lists all of the artists, you'd click on Leonardo da Vinci's name and it would take you to http://.../artist_page.php?artist=davinci. I'm not sure what that technique is called, but hopefully you all understand what I'm talking about.
I have added the code in the header of the artist_page.php to get the variables from the davinci.php so that I can echo them in my artist_page.php.
I want to set up the code on the artist_page.php so that the number of rows are dynamic and are based on the number of $image variables that are not null (or equal to "").
My idea was to set it up so that the artist_page.php would execute something like the following:
If the variable $image_1 is not null, then a row is created, and $image_1 populates the first cell in the row. Then (within this "if statement") I want to test to see if $image_2 is populated. If it isn't, then an empty cell is created. If $image_2 is populated, then it is outputted. Same thing with $image_3.
Then I want to test to see if the $image_4 is populated. If it is, then a new row is created and so on. If $image_4 is not populated, then our table closes.
Whenever I try to put the "if statement" for testing $image_2's value within the "if statement" for testing $image_1's value, I get an error. I have tried to do the code many different ways. Nothing works.
Perhaps I am setting this up the wrong way or perhaps my syntax is wrong. Any suggestions??