Jump to content

[SOLVED] shouldnt the echo produce the results


bigbenbuilders

Recommended Posts

im trying to replace with this

 

<?php if (stripos($_SERVER['REQUEST_URI'],'/id=1/') !== false) {echo 'class="alumni_tab_1_on_index"';} ?>

 

from this

 

<td width="105"><a href="index.php?option=com_content&task=category&sectionid=2&id=1&Itemid=37 " class="a_black text_10">

              <div class="tab_1" onMouseOver="this.className='tab_1_on_index'" onMouseOut="this.className='tab_1_index'">giving</div>

            </a></td>

Link to comment
Share on other sites

sorry this is like this

 

<td width="105"><a href="index.php?option=com_content&task=category&sectionid=2&id=1&Itemid=37 " class="a_black text_10">

              <div class="alumni_tab_1" onMouseOver="this.className='alumni_tab_1_on_index'" onMouseOut="this.className='alumni_tab_1_index'">giving</div>

            </a></td>

 

Link to comment
Share on other sites

well... just remove the backslashes and its fine...

 

<?php if (stripos($_SERVER['REQUEST_URI'],'id=1') !== false) {echo 'class="alumni_tab_1_on_index"';} ?>

 

just tested on my server. went to: http://localhost/text.php?id=1&poop=3

 

and it echoed what it was supposed to. IDK why you had those backslashes in there

Link to comment
Share on other sites

this is what I have with the full url in it and it is not working?

 

<div class="<?php if (stripos($_SERVER['REQUEST_URI'],'http://cuaa.info/index.php?option=com_content&task=category&sectionid=1&id=1&Itemid=2') !== false) {echo 'class="alumni_tab_1_index"';} ?>" onMouseOver="this.className='alumni_tab_1_on_index'" onMouseOut="this.className='alumni_tab_1_index'">alumni</div>

Link to comment
Share on other sites

firstly, the Request URI var of the server array returns the local path, not the full path.

 

if (stripos($_SERVER['REQUEST_URI'],'/index.php?option=com_content&task=category&sectionid=1&id=1&Itemid=2') !== false)

but why are you using stripos... you should be just comparing them because it seems like you only want to do this when this exact URL is gone to...

 

if ($_SERVER['REQUEST_URI'] == '/index.php?option=com_content&task=category&sectionid=1&id=1&Itemid=2'){

 

which is what i posted before...

Link to comment
Share on other sites

thanks for all your help mikesta707...it displays the word alumni and when I roll over it the tab pops up but it is not up like it is supposed to be at the begining like it is returning a false?  this is what I have

 

<div class="<?php if ($_SERVER['REQUEST_URI'] == '/index.php?option=com_content&task=category&sectionid=1&id=1&Itemid=2'){echo 'class="alumni_tab_1_index"';} ?>" onMouseOver="this.className='alumni_tab_1_on_index'" onMouseOut="this.className='alumni_tab_1_index'">alumni</div>

Link to comment
Share on other sites

dang I know I am close..now I get a blank page here is what I have

 


<div class="<?php if (this){ ($_SERVER['REQUEST_URI'] == '/index.php?option=com_content&task=category&sectionid=1&id=1&Itemid=2'){echo 'alumni_tab_1_index';}}
else {
echo "default echo";
} ?>" onMouseOver="this.className='alumni_tab_1_on_index'" onMouseOut="this.className='alumni_tab_1_index'">alumni</div>

Link to comment
Share on other sites

haha When i wrote if(this) i meant your original of statement, not to actually wrap what you had with if(this)

 


<div class="<?php if($_SERVER['REQUEST_URI'] == '/index.php?option=com_content&task=category&sectionid=1&id=1&Itemid=2') {echo 'alumni_tab_1_index';}
else {
echo "default echo";
} ?>" onMouseOver="this.className='alumni_tab_1_on_index'" onMouseOut="this.className='alumni_tab_1_index'">alumni</div>

Link to comment
Share on other sites

i dont quite understand, you want those to be tab1 when the same if statement above runs true. just put the ifstatement there

 

<div class="<?php if($_SERVER['REQUEST_URI'] == '/index.php?option=com_content&task=category&sectionid=1&id=1&Itemid=2') {echo 'alumni_tab_1_index';}
else {
echo "default echo";
} ?>" onMouseOver="this.className='<? if($_SERVER['REQUEST_URI'] == '/index.php?option=com_content&task=category&sectionid=1&id=1&Itemid=2') {echo 'tab1';}
else {
echo "default echo";
?>
'" onMouseOut="this.className='<? if($_SERVER['REQUEST_URI'] == '/index.php?option=com_content&task=category&sectionid=1&id=1&Itemid=2') {echo 'tab1';}
else {
echo "default echo";
?>'">alumni</div>

Link to comment
Share on other sites

if you want to affect multiple attributes I would suggest you preform the if statement before the output of the HTML, and store the attributes in variables. like

 

if($_SERVER['REQUEST_URI'] == '/index.php?option=com_content&task=category&sectionid=1&id=1&Itemid=2') {
$class = "alumni_tab_1_index";
$mouseOver="whatever';
$mouseOut = "whatever
}
else {
$class = "default value";
etc. etc.
}

and in your html

<div class="<?php echo $class; ?>" onMouseOver="this.className='<?php echo $mouseOver; ?>'" onMouseOut="this.className='a<?php echo $mouseOut; ?>'">alumni</div>

Link to comment
Share on other sites

mikeesta707 perfect but with just another little hitch the id=1 for that section will not change but the rest could and I need it to stay on when the id=1 regardless of the rest of the string...here is the code and it does work when I remove part of the string and switches...

 

<? if($_SERVER['REQUEST_URI'] == '/index.php?option=com_content&task=category&sectionid=1&id=1&Itemid=2') {
$class = 'alumni_tab_1_index';
$mouseOver='alumni_tab_1_on_index';
$mouseOut = 'alumni_tab_1_index';
}
else {
$class = 'tab_1';
$mouseOver = 'tab_1_on';
$mouseOut = 'tab_1';

}
?>
<div class="<?php echo $class; ?>" onMouseOver="this.className='<?php echo $mouseOver; ?>'" onMouseOut="this.className='<?php echo $mouseOut; ?>'">alumni</div>

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.