How to make an exception to an “if ….”

This is a discussion on "How to make an exception to an “if ….”" within the PHP Forum section. This forum, and the thread "How to make an exception to an “if ….” are both part of the Program Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Sep 9th, 2007, 19:20
Junior Member
Join Date: Aug 2006
Location: south australia
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Question How to make an exception to an “if ….”

I would like this 'if' to apply only if it is not on the home page and 2 other pages I dont want it on, as these pages already have login and home buttons

Code: Select all
 
<?php
if (!isset($flag_disable_header) || !$flag_disable_header) {
?>
 <li> <?php echo '<a href="' . HTTP_SERVER . DIR_WS_CATALOG . '">'; ?><?php echo HEADER_TITLE_CATALOG; ?></a></li>
<?php if ($_SESSION['customer_id']) { ?>
    <li><a href="<?php echo zen_href_link(FILENAME_LOGOFF, '', 'SSL'); ?>"><?php echo HEADER_TITLE_LOGOFF; ?></a></li>
    <li><a href="<?php echo zen_href_link(FILENAME_ACCOUNT, '', 'SSL'); ?>"><?php echo HEADER_TITLE_MY_ACCOUNT; ?></a></li>
 
 
<?php
      } else {
        if (STORE_STATUS == '0') {
?>
    <li><a href="<?php echo zen_href_link(FILENAME_LOGIN, '', 'SSL'); ?>"><?php echo HEADER_TITLE_LOGIN; ?></a></li>
<?php } } ?>
I got this code below but I have no idea how to make it for an 'if' exception

Code: Select all
 
<?php $slashpos = strrpos($_SERVER['REQUEST_URI'],"/");
if ($slashpos === false || $slashpos == strlen($_SERVER['REQUEST_URI'])) {
$thispage = $_SERVER['REQUEST_URI'];
}
else
{
$thispage = substr($_SERVER['REQUEST_URI'],$slashpos+1,strlen($_SERVER['REQUEST_URI'])-1);
}
if ($thispage == "index.php" || $thispage == "index.php?main_page=index" || $thispage == "") {
echo 'text for something I want to happen';
}
else
{
echo '' . META_TAG_TITLE . '' ;
} ?>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Sep 9th, 2007, 19:51
Junior Member
Join Date: Aug 2006
Location: south australia
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Re: How to make an exception to an “if ….”

I think I found a solution, I should just put the first if/else of the first code within the ‘if’ of the 2nd code
I will try it tomorrow as I have to go to bed now
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Sep 10th, 2007, 12:59
Junior Member
Join Date: Aug 2006
Location: south australia
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Re: How to make an exception to an “if ….”

I dont know what I need to do in order to get this if/else statment to work,

Code: Select all
 
<div id="headerWrapper">
<!--bof-navigation display-->
<div id="navMainWrapper">
<div id="navMain">
    <ul class="back">
    <li>&nbsp;&nbsp;&nbsp;&nbsp;
 
 
 
<?php $slashpos = strrpos($_SERVER['REQUEST_URI'],"/");
if ($slashpos === false || $slashpos == strlen($_SERVER['REQUEST_URI'])) {
$thispage = $_SERVER['REQUEST_URI'];
}
else
{
$thispage = substr($_SERVER['REQUEST_URI'],$slashpos+1,strlen($_SERVER['REQUEST_URI'])-1);
}
if ($thispage == "index.php" || $thispage == "index.php?main_page=index" || $thispage == "") {
echo '';
}
else
{

<?php
if (!isset($flag_disable_header) || !$flag_disable_header) {
?>
<?php echo '<a href="' . HTTP_SERVER . DIR_WS_CATALOG . '">'; ?><?php echo HEADER_TITLE_CATALOG; ?></a></li>
<?php if ($_SESSION['customer_id']) { ?>
    <li><a href="<?php echo zen_href_link(FILENAME_LOGOFF, '', 'SSL'); ?>"><?php echo HEADER_TITLE_LOGOFF; ?></a></li>
    <li><a href="<?php echo zen_href_link(FILENAME_ACCOUNT, '', 'SSL'); ?>"><?php echo HEADER_TITLE_MY_ACCOUNT; ?></a></li>
 
 
<?php
      } else {
        if (STORE_STATUS == '0') {
?>
    <li><a href="<?php echo zen_href_link(FILENAME_LOGIN, '', 'SSL'); ?>"><?php echo HEADER_TITLE_LOGIN; ?></a></li>
<?php } } ?>
<?php if ($_SESSION['cart']->count_contents() != 0) { ?>
    <li><a href="<?php echo zen_href_link(FILENAME_SHOPPING_CART, '', 'NONSSL'); ?>"><?php echo HEADER_TITLE_CART_CONTENTS; ?></a></li>
    <li><a href="<?php echo zen_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'); ?>"><?php echo HEADER_TITLE_CHECKOUT; ?></a>
} ?>
 
</li>
<?php }?>
</ul>
</div>
i think i will not bother as they are not paying me much and it is not necessary
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
php if exception

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Couldn't make it up... unitedcraig Webforumz Cafe 3 Jun 2nd, 2008 12:52
How to make IE 6 look like FF2 and IE7? Phil Web Page Design 23 Nov 16th, 2007 10:06
[SOLVED] How to make the PM pop up box? Monie JavaScript Forum 31 Nov 7th, 2007 08:38
how to make the border be red checkmate Web Page Design 17 Oct 29th, 2007 07:47
JAVA Exception abalfazl Other Programming Languages 3 Sep 9th, 2007 20:19


All times are GMT. The time now is 10:37.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42