Jump to content

if inside an echo


cmb

Recommended Posts

how can i put an if statement inside an echo this is what i want to do

<?php
echo "<li> <a  class='thumb' href='../images/Sections/pinkpanthers/" . $year . "/" . $sessions . "/" . $day . "/" . $y . ".jpg' title=''>
<img src='../images/Sections/pinkpanthers/" . $year . "/" . $sessions . "/" . $day . "/thumbs/" . $y . ".jpg ' /></a><div class='caption'>
<div	class='download'><a href='../images/Sections/pinkpanthers/" . $year . "/" . $sessions . "/" . $day . "/big/" . $y . ".jpg ' target='_blank' />Download</a>
</div><div class='image-desc'>" . if ($count == 1){echo "<a href='tag.php?tag=$name'" . $name . ">" . $name . "</a>";}if ($count > 1){$z = 0;$w = $count - 1;while ($z <= $w){$p = $multi[$z];echo "<a href='tag.php?tag=$p'" . $p . ">" . $p . "</a>";$z++;}} . "</div></div></li>";
?>

all the code works wright up until i added the if statements in the last little bit

Link to comment
https://forums.phpfreaks.com/topic/260434-if-inside-an-echo/
Share on other sites

i just broke up the echo so i could write this code here like this

<?php
while ($y <= $x){									
        $name = $tags[ $y . '.jpg'];
$multi = explode(',',$name);
$count = count($multi);
echo "<li> <a  class='thumb' href='../images/Sections/pinkpanthers/" . $year . "/" . $sessions . "/" . $day . "/" . $y . ".jpg' title=''><img src='../images/Sections/pinkpanthers/" . $year . "/" . $sessions . "/" . $day . "/thumbs/" . $y . ".jpg ' /></a><div class='caption'><div	class='download'><a href='../images/Sections/pinkpanthers/" . $year . "/" . $sessions . "/" . $day . "/big/" . $y . ".jpg ' target='_blank' />Download</a></div><div class='image-desc'>";
if ($count == 1){
	echo "<a href='tag.php?tag=$name'" . $name . ">" . $name . "</a>";
}
if ($count > 1){
	$z = 0;
	$w = $count - 1;
	while ($z <= $w){
		$p = $multi[$z];
		echo "<a href='tag.php?tag=$p'" . $p . ">" . $p . "</a> ";
		$z++;
	}
}
echo "</div></div></li>";
$y ++  ;	
}

?>

Link to comment
https://forums.phpfreaks.com/topic/260434-if-inside-an-echo/#findComment-1335012
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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