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
Share on other sites

how would i do this while part

<?php
$z = 0;
$w = $count - 1;
while ($z <= $w){
$p = $multi[$z];
$keys = "<a href='tag.php?tag=$p'" . $p . ">" . $p . "</a>";
$z++;
}
?>

because how i have it now it only shows 1 of the keywords not all of them

Link to comment
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
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.