Jump to content

Recommended Posts

It's the same except that it grows one number up to ten.

 

But it must start at 1.

 

 

  if ($img1==''){$img1="Image 1 <input type=file name='img1' id='img1' disabled><input type=hidden name=blank1 value='replace'>";}
  else{
  $img1="
  <a target=_blank href='$img1'>View Image 1</a> |  
  <a href='?page=secure/home&Spage=newProject&edit=$id&img=img1&rep=1&l=$img1'>Replace Image 1</a>
  <input type=hidden name=blank1 value='$img1'>
  ";
  }
  
  
  if ($img2==''){$img2="Image 2 <input type=file name='img2' id=img2 disabled><input type=hidden name=blank2 value='replace'>";}
  else{
  $img2="
  <a target=_blank href='$img2'>View Image 2</a> |  
  <a href='?page=secure/home&Spage=newProject&edit=$id&img=img2&rep=1&l=$img2'>Replace Image 2</a>
  <input type=hidden name=blank2 value='$img2'>
  ";
  }
  
  
  
    if ($img3==''){$img3="Image 3 <input type=file name='img3' id=img3><input type=hidden name=blank3 value='replace'>";}
  else{
  $img3="
  <a target=_blank href='$img3'>View Image 3</a> |  
  <a href='?page=secure/home&Spage=newProject&edit=$id&img=img3&rep=1&l=$img3'>Replace Image 1</a>
  <input type=hidden name=blank3 value='$img3'>
  ";
  }
  

    if ($img4==''){$img4="Image 4 <input type=file name='img4'><input type=hidden name=blank4 value='replace'>";}
  else{
  $img4="
  <a target=_blank href='$img4'>View Image 4</a> |  
  <a href='?page=secure/home&Spage=newProject&edit=$id&img=img1&rep=1&l=$img4'>Replace Image 4</a>
  <input type=hidden name=blank4 value='$img4'>
  ";
  }
  
  
    if ($img5==''){$img5="Image 5 <input type=file name='img5'><input type=hidden name=blank5 value='replace'>";}
  else{
  $img5="
  <a target=_blank href='$img5'>View Image 5</a> |  
  <a href='?page=secure/home&Spage=newProject&edit=$id&img=img5&rep=1&l=$img1'>Replace Image 5</a>
  <input type=hidden name=blank5 value='$img5'>
  ";
  }
  
  
    if ($img6==''){$img6="Image 6 <input type=file name='img6'><input type=hidden name=blank6 value='replace'>";}
  else{
  $img6="
  <a target=_blank href='$img6'>View Image 6</a> |  
  <a href='?page=secure/home&Spage=newProject&edit=$id&img=img6&rep=1&l=$img6'>Replace Image 6</a>
  <input type=hidden name=blank6 value='$img6'>
  ";
  }
  
  
    if ($img7==''){$img7="Image 7 <input type=file name='img7'><input type=hidden name=blank7 value='replace'>";}
  else{
  $img7="
  <a target=_blank href='$img7'>View Image 7</a> |  
  <a href='?page=secure/home&Spage=newProject&edit=$id&img=img7&rep=1&l=$img7'>Replace Image 7</a>
  <input type=hidden name=blank7 value='$img7'>
  ";
  }
  
  
    if ($img8==''){$img8="Image 8 <input type=file name='img8'><input type=hidden name=blank8 value='replace'>";}
  else{
  $img8="
  <a target=_blank href='$img8'>View Image 8</a> |  
  <a href='?page=secure/home&Spage=newProject&edit=$id&img=img8&rep=1&l=$img8'>Replace Image 8</a>
  <input type=hidden name=blank8 value='$img8'>
  ";
  }

You should get a good laugh from this.  
  
    if ($img9==''){$img9="Image 9 <input type=file name='img9'><input type=hidden name=blank9 value='replace'>";}
  else{
  $img9="
  <a target=_blank href='$img9'>View Image 9</a> |  
  <a href='?page=secure/home&Spage=newProject&edit=$id&img=img9&rep=1&l=$img9'>Replace Image 9</a>
  <input type=hidden name=blank9 value='$img9'>
  ";
  }
  
  
    if ($img10==''){$img10="Image 10 <input type=file name='img10'><input type=hidden name=blank10 value='replace'>";}
  else{
  $img10="
  <a target=_blank href='$img10'>View Image 10</a> |  
  <a href='?page=secure/home&Spage=newProject&edit=$id&img=img1&rep=1&l=$img10'>Replace Image 10</a>
  <input type=hidden name=blank10 value='$img10'>
  ";
  }

Link to comment
https://forums.phpfreaks.com/topic/120336-solved-please-help-shorten-this-code/
Share on other sites

Expand on something like the following:

 

<?php
$images = array(1,2,3,4,5);
foreach($images as $imageNum) {
  print "Image ".$imageNum." <input type=file name='img".$imageNum."' id='img".$imageNum."' disabled><input type=hidden name=blank".$imageNum." value='replace'><br />";
}
?>

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.