Forum Moderators: coopster
it can be written like so
if($picnr==1){
echo("");
} else {
echo "<a href=\"".$urlprev."\">previous picture </a>"";
}
with echo you can put a comma between the different elements instead of concatenating them together, this is actually faster than having to cat it first and then echo it. So like so
if($picnr==1){
echo("");
} else {
echo "<a href=\"",$urlprev,"\">previous picture </a>"";
}
if statements that are followed with only a single line do not need braces therefore this way
if($picnr==1) echo("");
else echo "<a href=\"",$urlprev,"\">previous picture </a>"";
as yowza mentioned, if you need it to do nothing when $picnr==1 then do the inverse and leave out the else all together, if the test is false nothing will happen
if($picnr!= 1) echo "<a href=\"",$urlprev,"\">previous picture </a>"";
seems the shortest way ;)
<added>I try to always have the most common case appear first. So if you wanted to actually echo something when $picnr == 1 do it this way
if($picnr!= 1) echo "<a href=\"",$urlprev,"\">previous picture </a>"";
else echo ' ';