Page 1 of 1

what am i doing wrong now :(

Posted: Tue Aug 10, 2004 4:16 pm
by pinehead18

Code: Select all

<?php
        $topic_table .= "
                <table class="table2"
                <tr>
                 <td width=90% valign=top bgcolor=#CDCDCD>$author | :  $cdate | Posted By:<a 
href=http://www.kcchristians.com/myprofile/$author/>$author</a>
                  Posts: $posts</td><td align=right width=10%>
". if ($admin == 1) $topic_table .= "Delete Thread
- Edit"; } { $topic_table .= "&nbsp;"; } ."
</td></tr><tr><td width=100%>". nl2br($body) ."<br>
                </td>
                </tr>   
                </table>
";
     
?>
Erroring out on me where the ". if starts. "

thank you for your help and for understanding my grand newby ness

Posted: Tue Aug 10, 2004 4:49 pm
by markl999
I prefer doing it like:

Code: Select all

<?php
$edit = ($admin == 1) ? 'Delete Thread - Edit' : ' ';
$body = nl2br($body);
$topic_table .= <<< EOD
  <table class="table2"
    <tr>
      <td width="90%" valign="top" bgcolor="#CDCDCD">
        $author | :  $cdate | Posted By:<a href="http://www.kcchristians.com/myprofile/{$author}/">{$author}</a>
        Posts: {$posts}
      </td>
      <td align="right" width="10%">{$edit}</td>
    </tr>
    <tr>
      <td width="100%">{$body}<br></td>
    </tr>
  </table>
EOD;

Posted: Tue Aug 10, 2004 4:49 pm
by Buddha443556
Try a ternary operator:

Code: Select all

<?php 
        $topic_table .= " 
                <table class="table2" 
                <tr> 
                 <td width=90% valign=top bgcolor=#CDCDCD>$author | :  $cdate | Posted By:<a 
href=http://www.kcchristians.com/myprofile/$author/>$author</a> 
                  Posts: $posts</td><td align=right width=10%> 
". ($admin == 1 ?  "Delete Thread - Edit" : " " ) ." 
</td></tr><tr><td width=100%>". nl2br($body) ."<br> 
                </td> 
                </tr>    
                </table> 
";  
?>
"if" is a control statement and doesn't really belong in the middle of a string.

Posted: Tue Aug 10, 2004 4:51 pm
by Buddha443556
I like markl999's answer better. Nice style.

Posted: Tue Aug 10, 2004 5:20 pm
by pinehead18
still getting this error arse error: parse error, unexpected T_IF

Thank you
Anthony

Posted: Wed Aug 11, 2004 11:05 am
by pinehead18
What is this EOD method being used? Do you have any documentation anywhere on it?


I swear everytime i turn around their is a new way of doing things :(

Posted: Wed Aug 11, 2004 11:42 am
by feyd
it's called a heredoc.