SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Wizard
    Join Date
    May 2002
    Posts
    1,370
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    conditional echo

    This is really starting to get embarassing, as many times as I've done something so similiar.

    Can anyone tell me why this is echoing THE EMPTY SPACE AND COMMA ( and not just the empty space) when the col contains the 5?

    PHP Code:
    if($row_query['colA']=='5'
    {echo
    '';} else {echo $row_query['colA'].', ';}
    if(
    $row_query['colB']=='5'
    {echo
    '';} else {echo $row_query['colB'].', ';} 

  2. #2
    SitePoint Member
    Join Date
    Jun 2007
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ** snipped due to lack of reading comprehension**
    Last edited by rgilmanhunt; Aug 10, 2007 at 20:50.

  3. #3
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    if ($row_query['colA'] != '5') {
        echo 
    $row_query['colA'] . ', ';
    }

    if (
    $row_query['colB'] != '5') {
        echo 
    $row_query['colB'] . ', ';
    }

    # OR

    echo ($row_query['colA'] != '5') ? $row_query['colA'] . ', ' '';
    echo (
    $row_query['colB'] != '5') ? $row_query['colB'] . ', ' ''
    Remember there is a space bar >.>
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  4. #4
    SitePoint Wizard
    Join Date
    May 2002
    Posts
    1,370
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it prints right.

    was a simple syntax error. resolved.

    thank you.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •