php 101 .. probably the easiest question here but I have no idea (please help!)

Hi Everyone, I’m trying to edit some fairly straight forward php code and I have very minimal experience. I thought I’d get lucky simply cutting and pasting the arguments I wanted but alas, no dice. Hopefully someone here can assist.

Essentially all I’m trying to do is take the existing code that contains a php reference:

[php] main-slider-photo [/php]

…and add an “if, then” type of element to it. Something like:

[php] //if listing has no photo, use default photo in images/nophoto.gif in images folder
else
$imgUrl = get_bloginfo(“template_url”) . “/ygl-assets/images/nophoto.gif”;
?>[/php]

The idea is that if there is no image to display (on the site in question), then it will use the default image. As it is, every time there isn’t an image it starts screwing up other elements of the page (another leg of my education to be sure but one thing at a time).

Every attempt at mixing the two together renders the page blank on load (probably because I’m doing it very wrong).

Can anyone help?

Thank you!

The whole thing should be on one IF statement.

If there is a photo - echo that picture else echo default picture.

[php]

IF ($img==1) {echo ‘’;}//if there is an image 1=true then echo that image

else {echo $defaultimg;} //if it is false -no image- then echo default image
[/php]

think I understood what you meaaaan.

Sponsor our Newsletter | Privacy Policy | Terms of Service