SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru
    Join Date
    Feb 2006
    Location
    Chepstow, South Wales
    Posts
    760
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    php and html in echo output

    I am using php with MSSQL, and I have this line below, which to me looks right, but its breaking the page.

    PHP Code:
    echo "<td width='60' class='tableData'>".if ($data["Group_Member"]==1){."Yes".}else{."No".}."</td>"
    Can somebody tell me where I'm going wrong with it.

    Cheers

  2. #2
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    4,810
    Mentioned
    141 Post(s)
    Tagged
    0 Thread(s)
    Code php:
    echo "<td width='60' class='tableData'>".(($data["Group_Member"]==1)?"Yes":"No")."</td>";

    You need to use a ternary operator, or you need to rewrite it like so:
    Code php:
    echo "<td width='60' class='tableData'>";
    if ($data["Group_Member"]==1){
      echo "Yes";
    } else {
      echo "No";
    }
    echo "</td>";

  3. #3
    SitePoint Guru
    Join Date
    Feb 2006
    Location
    Chepstow, South Wales
    Posts
    760
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you cpradio,

    I understand that now, and it worked fine.

    Cheers


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
  •