• Hello, I want to display something if the width of a game is <=600, and if the width is >600 I want to display nothing… how can I do that? I tried to make a function but doesn’t work.

    <?php
    function blabla($blabla = '<?php $values = get_post_custom_values("width"); echo $values[0]; ?>') {
    if ( $blabla <= 600) $blabla= "<div style='float:right'>afffff</div>";
    }
    ?>
Viewing 5 replies - 1 through 5 (of 5 total)
  • try:

    <?php
    function blabla {
    $values = get_post_custom_values("width"); $blabla =  $values[0];
    if ( $blabla <= 600) $blabla= "<div style='float:right'>afffff</div>";
    }
    ?>
    Thread Starter delgado2009

    (@delgado2009)

    Parse error: syntax error, unexpected ‘{‘, expecting ‘(‘ in /home/content/html/…/functions.php on line 24

    Doesn’t work ??

    my bad, i forgot the parameter brackets for the function:

    <?php
    function blabla() {
    $values = get_post_custom_values("width"); $blabla =  $values[0];
    if ( $blabla <= 600) $blabla= "<div style='float:right'>afffff</div>";
    }
    ?>

    it is also possible that i misunderstood your original idea in your code (?)

    Thread Starter delgado2009

    (@delgado2009)

    And if I want to do something like : if is width<=600 display something, if is width > 600 and width < 750 display something, and if is width > 750 display something… how can I do that? ??

    https://www.w3schools.com/php/php_if_else.asp

    <?php
    function blabla() {
    $values = get_post_custom_values("width"); $blabla =  $values[0];
    if ( $blabla <= 600) { /*do something*/ }
    elseif( $blabla > 600 && $blabla < 750 ) { /*do something*/  }
    elseif( $blabla >= 750 ) { /*do something*/ }
    }
    ?>
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Function width’ is closed to new replies.