Jump to content

for loop


Woodburn2006

Recommended Posts

i have a database with fields named img1, img2, img3 up to img8. some of these fields hold paths to images and some of them have a value of 'x' just to show there is no image present.

 

i am making a page that shows these images but i need it to only show the fields that have an image in it, i have put together a simple bit of script but i was wondering if there is an easier way of doing it using a for loop or omething similar.

 

heres what i have got:

 

	if($img1 != "x"){echo "<img src='$img1' width='150' border='0'><br /><br />";}
if($img2 != "x"){echo "<img src='$img2' width='150' border='0'><br /><br />";}
if($img3 != "x"){echo "<img src='$img3' width='150' border='0'><br /><br />";}
if($img4 != "x"){echo "<img src='$img4' width='150' border='0'><br /><br />";}
if($img5 != "x"){echo "<img src='$img5' width='150' border='0'><br /><br />";}
if($img6 != "x"){echo "<img src='$img6' width='150' border='0'><br /><br />";}
if($img7 != "x"){echo "<img src='$img7' width='150' border='0'><br /><br />";}
if($img8 != "x"){echo "<img src='$img8' width='150' border='0'><br /><br />";}

 

any help would be much appreciated

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.