Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7590859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:30:37+00:00 2026-05-30T20:30:37+00:00

I know this is a weird question, but let me explain more. I use

  • 0

I know this is a weird question, but let me explain more. I use codeigniter as framework to make my site. I have some code that contain if else condition in view and want to use that as a href so it becomes like a button that changes based on whether the condition has been met or not.

here is the code:

<?php if($this->tank_auth->is_logged_in())
{      echo anchor("auth/logout/","Logout");
}      else { 
       echo anchor("auth/login/","Login");
?>

I was looking around in the net, but couldn’t find a similar case where if else statement being used.

any idea how to achieve that?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T20:30:38+00:00Added an answer on May 30, 2026 at 8:30 pm

    That should work fine, as long as tank_auth is loaded and you have a closing bracket after your else condition:

    <?php 
    if($this->tank_auth->is_logged_in()) {
      echo anchor("auth/logout/","Logout");
    } else { 
      echo anchor("auth/login/","Login");
    }
    ?>
    

    You might also consider moving your check for the user’s login to your controller, however, so as to keep tank_auth out of your views:

      // ...end of controller function
      $data['logged_in'] = $this->tank_auth->is_logged_in();
      $this->load->view('my_view', $data);
    }
    

    In this case, you would then run your conditional on $logged_in in your view.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this question sounds weird, but please, let me explain myself. I'm using
i know this question was asked before but i have this very weird beginner
I know this is a weird question to ask, but I would like to
I know this isn't strictly a programming question but y'all must have experienced this.
Weird question, but I have a dictionary created with StringComparer.OrdinalIgnoreCase, looks something like this
This is weird question but I want to know how to change message coming
I know this is a weird question, but I would like to know if
This is a weird requirement I have. I know even my question is quite
I know this may sound like a weird question to ask but I would
I have this weird question. I would like to know if it is possible

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.