Jump to content

Recommended Posts

okay so what im wanting is for the 3 if statements below to be combined into the same div class...

 

so instead of 3 seperate <div>s instead its all in 1.

 

if($player->hospital >= 1)
{
echo "<div class="g_content"><h3>  Notifications</h3><div class=\"g_text\">	<center><a href=\"../hospital.php\">You Are In Hospital [\" . $player->hospital . \"mins left]</a><br></center></div></div>;";
}
?>

 

if($player->prison >= 1)
{
echo "<div class="g_content"><h3>  Notifications</h3><div class=\"g_text\">	<center><a href=\"../prison.php\">You Are In Prison [\" . $player->prison . \"mins left]</a><br></center></div></div>;";
}
?>

 

if($player->news >= 1)
{
echo "<div class="g_content"><h3>  Notifications</h3><div class=\"g_text\">	<center><a href=\"../news.php\">You have unread News</a><br></center></div></div>;";
}
?>

 

 

 

so instead of the above it would be something like this...

 

<?php
if($player->hospital >= 1 || $player->prison >= 1 || $player->news >= 1)
{
echo "<div class="g_content"><h3>  Notifications</h3><div class=\"g_text\">";

if(player->hospital >= 1)
{
echo "<center><a href=\"../hospital.php\">You Are In Hospital [\" . $player->hospital . \"mins left]</a><br></center>";
}

if(player->prison >= 1)
{
echo "<center><a href=\"../prison.php\">You Are In Prison [\" . $player->prison . \"mins left]</a><br></center>";
}

if(player->news >= 1)
{
echo "<center><a href=\"../news.php\">You have unread News</a><br></center>";
}
echo "</div></div>;\";";
}
}
?>

 

 

Link to comment
https://forums.phpfreaks.com/topic/158158-solved-echoing-tags-in-if-statements/
Share on other sites

so something like this??

 

<?php
if($player->hospital >= 1 || $player->prison >= 1 || $player->news >= 1)
{
echo "<div class=\"g_content\"><h3>  Notifications</h3><div class=\"g_text\">";

if(player->hospital >= 1)
{
echo "<center><a href=\"../hospital.php\">You Are In Hospital [\" . $player->hospital . \"mins left]</a><br></center>";
}

if(player->prison >= 1)
{
echo "<center><a href=\"../prison.php\">You Are In Prison [\" . $player->prison . \"mins left]</a><br></center>";
}

if(player->news >= 1)
{
echo "<center><a href=\"../news.php\">You have unread News</a><br></center>";
}
echo "</div></div>;\";";
}
}
?>

 

this doesnt look right at all

 

echo "</div></div>;\";";

 

 

 

the other problem i might have is that this php code itself is inside a set of <div> tags

This line

echo "</div></div>;\";";

should be outside of your last if statement.

 

if($player->hospital >= 1 || $player->prison >= 1 || $player->news >= 1)
{
    echo "<div class=\"g_content\"><h3>  Notifications</h3><div class=\"g_text\"><center>";

    if($player->hospital >= 1)
    {
        echo "<a href=\"../hospital.php\">You Are In Hospital [\" . $player->hospital . \"mins left]</a><br>";
    }

    if($player->prison >= 1)
    {
        echo "<a href=\"../prison.php\">You Are In Prison [\" . $player->prison . \"mins left]</a><br>";
    }

    if($player->news >= 1)
    {
        echo "<a href=\"../news.php\">You have unread News</a><br>";
    }

    echo "</center></div></div>";
}

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.