In this code if $row['division'] is Leech it shows the link of related page. When $row['division'] is DME it's showing blank space and even it's not showing the last part of else statement.
<td>
<a rel="facebox"
<?php if ($row['division']=="Leech") { ?>
href="viewevaldme.php?evaid=<?php echo $row['evaid']; ?>" >
<?php } elseif ($row['division']=="DME") { ?>
href="vieweval.php?evaid=<?php echo $row['evaid']; ?> "
<?php } else { echo "Wrong Division Selected"; } ?>
Click Here
</a>
</td>
Try This :
<td>
<?php
if ($row['division'] == "Leech") {
echo '<a rel="facebox" href="viewevaldme.php?evaid='.$row['evaid'].'">Click Here</a>';
} elseif($row['division'] =="DME") {
echo '<a rel="facebox" href="vieweval.php?evaid='.$row['evaid'].'">Click Here</a> ';
} else {
echo 'Wrong Division Selected';
}
?>
</td>
Try this:
<td>
<?php
if ($row['division'] === "Leech") {
print '<a rel="facebox" href="viewevaldme.php?evaid='.$row['evaid'].'">Click Here</a>';
} elseif($row['division']==="DME") {
print '<a rel="facebox" href="vieweval.php?evaid='.$row['evaid'].'">Click Here</a> ';
} else {
print 'Wrong Division Selected';
}
?>
</td>
Related
i have issue with my php code .
First i have Database with Photo link then i add this with echo .
I Fill the Database with /upload/photo-1.png or what ever from the User !
<?php echo$photo; ?>
I add this with :
<?php if(!empty($photo)) {echo 'uploads/photodefault.png'; } ?>
you can write like this
<?php if(!empty($photo))
{
echo $photo;
}
?>
Edit 1:
If photo is not empty then it will show link.
Change your code to this
<?php
if(empty($photo)) {
echo "uploads/photodefault.png";
} else {
echo $photo;
}
?>
With an <img> tag example
<img src="<?php if(empty($photo)) { echo "uploads/photodefault.png"; } else { echo $photo; } ?>">
try the following code
if ($photo != ''){
echo $photo;
}else{
echo "uploads/photodefault.png";
}
<?php if(!empty($photo)) { echo $photo; } else { echo 'default/default_large.png'; } ?>
This fixed my issue.
Is there a way to add a button for a if/else statement? This is my code
<?php if(isset($_SESSION["steamname"]))
//If steamname not equals 0
{
<a class="button-logout" href="steamauth/logout.php">Log Out</a>
}
else
{
<a class="button-login" href="steamauth/login_steam.php">Log In</a>
}
?>
But my server keeps saying that it's a invalid. My understanding of php isn't that great but what I'm trying to do is to make it so that if a user is logged in a logout button will appear and if not it will be login. My current method doesn't work so is it even possible? Thanks.
P.S. I've tried echoing it out, no luck either.
P.S.S I don't think it has anything to do with my isset command. I did a plain echo and it worked out fine.
You need to echo the HTML you want:
<?php if(isset($_SESSION["steamname"]))
//If steamname not equals 0
{
echo '<a class="button-logout" href="steamauth/logout.php">Log Out</a>';
}
else
{
echo '<a class="button-login" href="steamauth/login_steam.php">Log In</a>';
}
?>
Without the echo, PHP will try to parse your HTML as PHP, which won't work.
change your code to. You have to put html tags out side PHP
<?php if(isset($_SESSION["steamname"]))
{ ?>
<a class="button-logout" href="steamauth/logout.php">Log Out</a>
<?php }
else
{ ?>
<a class="button-login" href="steamauth/login_steam.php">Log In</a>
<?php } ?>
OR
You can echo html tags
<?php if(isset($_SESSION["steamname"]))
{
echo '<a class="button-logout" href="steamauth/logout.php">Log Out</a>';
}
else
{
echo '<a class="button-login" href="steamauth/login_steam.php">Log In</a>';
}
?>
If you don't want to echo html as a string, you can do it like this with alternative syntax:
<?php if(isset($_SESSION['steamname'])): ?>
<a class="button-logout" href="steamauth/logout.php">Log Out</a>
<?php else: ?>
<a class="button-login" href="steamauth/login_steam.php">Log In</a>
<?php endif; ?>
i would like to change a link to target="_blank" (opening in a new window, or tab) but can#t fix it. i´m a fool in php and my try&error-method did´t work. can anybody help me?
Thank you so much!
original code from the parallax one theme (wordpress)
<?php
if(!empty($parallax_one_contact_info_item_decoded)){
foreach($parallax_one_contact_info_item_decoded as $parallax_one_contact_item){
if(!empty($parallax_one_contact_item->link)){
echo '<div class="col-sm-4 contact-link-box col-xs-12">';
if(!empty($parallax_one_contact_item->icon_value)){
echo '<div class="icon-container"><span class="'.esc_attr($parallax_one_contact_item->icon_value).' colored-text"></span></div>';
}
if(!empty($parallax_one_contact_item->text)){
echo ''.$parallax_one_contact_item->text.' ';
}
echo '</div>';
} else {
echo '<div class="col-sm-4 contact-link-box col-xs-12">';
if(!empty($parallax_one_contact_item->icon_value)){
echo '<div class="icon-container"><span class="'.esc_attr($parallax_one_contact_item->icon_value).' colored-text"></span></div>';
}
if(!empty($parallax_one_contact_item->text)){
if(function_exists('icl_translate')){
echo ''.icl_translate('Contact',$parallax_one_contact_item->id.'_contact',esc_attr($parallax_one_contact_item->text)).'';
} else {
echo ''.esc_attr($parallax_one_contact_item->text).'';
}
}
echo '</div>';
}
}
}
?>
Simply add target="_blank" in your anchor tag. For example :
echo '<a target="_blank" href="'.$parallax_one_contact_item->link.'" class="strong">'.$parallax_one_contact_item->text.' </a>';
Try this:
<?php
if(!empty($parallax_one_contact_info_item_decoded)){
foreach($parallax_one_contact_info_item_decoded as $parallax_one_contact_item){
if(!empty($parallax_one_contact_item->link)){
echo '<div class="col-sm-4 contact-link-box col-xs-12">';
if(!empty($parallax_one_contact_item->icon_value)){
echo '<div class="icon-container"><span class="'.esc_attr($parallax_one_contact_item->icon_value).' colored-text"></span></div>';
}
if(!empty($parallax_one_contact_item->text)){
echo '<a target="_blank" href="'.$parallax_one_contact_item->link.'" class="strong">'.$parallax_one_contact_item->text.' </a>';
}
echo '</div>';
} else {
echo '<div class="col-sm-4 contact-link-box col-xs-12">';
if(!empty($parallax_one_contact_item->icon_value)){
echo '<div class="icon-container"><span class="'.esc_attr($parallax_one_contact_item->icon_value).' colored-text"></span></div>';
}
if(!empty($parallax_one_contact_item->text)){
if(function_exists('icl_translate')){
echo '<a target="_blank" href="" class="strong">'.icl_translate('Contact',$parallax_one_contact_item->id.'_contact',esc_attr($parallax_one_contact_item->text)).'</a>';
} else {
echo '<a target="_blank" href="" class="strong">'.esc_attr($parallax_one_contact_item->text).'</a>';
}
}
echo '</div>';
}
}
}
?>
Note: Added target="_blank" in each hyperlink.
What is wrong here..
<?php if($user->getSession()){
echo '<li>My Profile</li>';
}else{
echo '<li><a class="button" href="#prvi">Join Us</a></li>';
} ?>
The result of this:
index.php?page=25&id=<?php%20echo%20$user[id];%20?>
Modify your code accordingly :
if($user->getSession()){
echo '<li>My Profile</li>';
}else{
echo '<li><a class="button" href="#prvi">Join Us</a></li>';
}
Change
This
<?php
if($user->getSession()){
echo '<li>My Profile</li>';
}else{
echo '<li><a class="button" href="#prvi">Join Us</a></li>';
}
?>
Into this
<?php
if($user->getSession()){
echo '<li>My Profile</li>';
}else{
echo '<li><a class="button" href="#prvi">Join Us</a></li>';
}
?>
PHP tag is not necessary inline of echo, that is your error.
Update
The $user variable is a object but used as an array.
In you code, change
echo '<li>My Profile
to this
echo '<li>My Profile
In object you have to refer to its key with -> as in arrays you do []
I am surprised to see my top login bar cannot show any change after user login.
Other element of in this bar like logo, decorative div show as it but after 'login to change username' & 'registration to change logout' & 'all notification' display like I am not logged in.
I cannot understand where is my wrong. It cannot show any error also.
Please see my code:
Included my every pages:
<?php include_once("top_login.php"); ?>
my top_login.php
<?php include_once("login/session.php"); ?>
<div id="toplogin">
<div class="logintext1">
<?
if($session->logged_in){
echo '<a class="logintext" href=../login/myprocess.php>Logout</a>';
} else {
echo '<a class="logintext" href="../login/regis.php">Register</a>';
}
?>
</div>
<div class="logintext2">
<?
if($session->logged_in){
echo '<a class="logintext" href="../login/mn.php">'.$_SESSION["username"].'</a>';
} else {
echo '<a class="logintext" href="../login/mn.php">Log In</a>';
}
?>
</div>
<div class="logintext3">
<?
if($session->logged_in){
echo '<a class="logintext" href="#"><img style="padding:2px 2px" src="http://www.mywebsite.com/images/nof2.png" /></a>';
} else {
echo '<a class="logintext" href="../login/mn.php"><img style="padding:2px 2px" src="http://www.mywebsite.com/images/nof.png" /> </a>';
}
?>
</div>
</div>