Jump to content

Php if statemant help needed


nocniagenti

Recommended Posts

OK friends I need a small if statemant to help me change width of the div's

the explanation should be like this

 

if  user2 and user3 modules are published (this are 2 horizontal modules

that are placed inside a div #mid width=950px )

 

user2 widht= 530px

user3 width=390px

 

if only user2 module is  published

 

user2 width=950px

 

and finaly if only user3 module is  published

 

user3 width=950px

 

this is what I have so far and only the first statmeant is working like it shold.

the other 2 always stay at  532px or 390px depends if user3 or user2 is published only

 

 


<?php 
$newsflash = 0;
$banner= 0 ;
if (mosCountModules('user2')) $banner++; 
if (mosCountModules('user3')) $newsflash++;
if (( $newsflash == 1 ) || ( $banner == 1 )) {
    $newsflashdivwidth = '390px';
    $bannerwidth = '532px';
     } else if (( $banner == 1 ) || ( $newsflash == 0 )) { 
    $bannerwidth = '950px';
    } else if (( $banner == 0 ) || ( $newsflash == 1 )) {
    $newsflashdivwidth = '950px';
?>

 

and this is the call for user2 and user3

 

<!-- NEWSFLASH MODULES -->
    <?php if (mosCountModules('user2') || mosCountModules('user3')) { ?>
        <div id="midsh"> 
        <div id="mid"><?php if (mosCountModules('user2')) { ?>
        <div id="banner" style="width:<?php echo $bannerwidth ?>;"> 
        <?php mosLoadModules ( 'user2' ); ?></div><?php } ?> 
        <?php if (mosCountModules('user3')) { ?>
        <div id="newsflash" style="width:<?php echo $newsflashdivwidth ?>;">
        <?php mosLoadModules ('user3');?></div><?php } ?> 
        </div>
        </div><?php } ?>

 

thank you

Link to comment
https://forums.phpfreaks.com/topic/40779-php-if-statemant-help-needed/
Share on other sites

love you guys

both of you where right

the last post made it work

code looks like this now

 

<?php
$newsflash = 0;
$banner= 0 ;
if (mosCountModules('user2')) $banner++;
if (mosCountModules('user3')) $newsflash++;
if (( $newsflash == 1 ) && ( $banner == 1 )) {
    $newsflashdivwidth = '390px';
    $bannerwidth = '532px';
     } elseif (( $banner == 1 ) && ( $newsflash == 0 )) {
    $bannerwidth = '946px';
    } elseif (( $banner == 0 ) && ( $newsflash == 1 )) {
    $newsflashdivwidth = '946px';


}
?>

 

it was suposed to be && not ||

 

thank you!!!!

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.