Jump to content

jacchops

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

jacchops's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. What if I don't want the first "if... echo..." to stop? I actually have another row underneath this row that outputs the title of the image. That variable is $image_1_title, $image_2_title, etc. If there is no $image_2, then the #image_2_title will be equal to null. So if I use a ";" to stop the echoing of the first "if statement", then the row with the image title's won't show up if there is no value for $image_2. But I only want that row to show up if there is at least an $image_1. I figured that even if there is an $image_1 but no $image_2 or $image_3, I could still output the $image_2_title and the $image_3_title since they will just be empty values. This is why I wanted to test for a value for $image_2 and $image_3 WITHIN the test for an $image_1. I hope that makes sense. (And the assumption that there is no image 2 without an image 1 is correct.) <?php if ($image_1!=="") { echo '<tr> <td><a href="#"><img src="' . $image_1 . 'height="150" border="0" /></a></td> <td><a href="#"><img src="' . if ($image_2!=="") echo "$image_2" . 'height="150" border="0" /></a></td> <td><a href="#"><img src="' . if ($image_3!=="") echo "$image_3" . 'height="150" border="0" /></a></td> </tr> <tr> <td>' . $image_1_title . '...</td> <td>' . $image_2_title . '...</td> <td>' . $image_3_title . '...</td> </tr>'; } ?>
  2. I didn't say this before, and I don't think it matters, but $image_1 is actually populated with a location for the image. When I run this code without the second and third <td>s, the $image_1 outputs correctly. But if I run it as it is below, I get the following error related to the line of code in the second <td>: "Parse error: syntax error, unexpected T_IF" <?php if ($image_1!=="") { echo '<tr> <td><a href="#"><img src="' . $image_1 . 'height="150" border="0" /></a></td> <td><a href="#"><img src="' . if ($image_2!=="") echo "$image_2" . 'height="150" border="0" /></a></td> <td><a href="#"><img src="' . if ($image_3!=="") echo "$image_3" . 'height="150" border="0" /></a></td> </tr>'; } ?> Please use the CODE tags when posting code
  3. 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??
  4. Here is so more info to help explain the problem. Let's say I have a website with 3 html pages: Home, About Me, Images. There is an identical menu at the top of each of these pages that looks like this: Home | About Me | Images When you click on "Home", it brings you to home.html, when you click on "About Me", it brings you to aboutme.html, etc. Since this navigation menu is the same on every page, I have made it a library (or template) item. So that if I open the template and change the text "Home" to "Welcome", then when I save it, all 3 of my pages will automatically be updated with the new menu: Welcome | About Me | Images When I am viewing the home.html page, I want the text "Welcome" in the navigation menu on the top of the page to be bold and red. When I click on "About Me" and go to the aboutme.html, I want the "Welcome" text to go back to it's original size and color and "About Me" to be bold and red. I'd like to do this with a server-side script so that no browser plug-ins are required to view. And I also want to keep my menu as a template, as it frequently changes.
  5. Please forgive the ignorance; I am new to php. Could someone please tell me if it possible to do the following with php (or any other server-side scripts): Say you have a left menu that stays the same on every page within in your site. Obviously you would make this menu a template or library item, so that when you edit one version, all the others are updated. Let's say the left menu is the following: Page_1 Page_2 Page_3 Now, when I am viewing Page_1, I want the "Page_1" text in the left menu to be red, so that the viewer knows what page they are on. When I click on the left menu link for "Page_2", then I want the "Page_1" text to go back to black and the "Page_2" text to be red. Can it be done?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.