runnerjp Posted February 12, 2010 Share Posted February 12, 2010 How do i write this correctly....not sure where i have i gone wrong <?php echo '<tr $class = ($important == 1) ? 'mainrow1' : 'mainrow'; class="\$class"\> Quote Link to comment Share on other sites More sharing options...
Deoctor Posted February 12, 2010 Share Posted February 12, 2010 i think u forgot to post the remaining code.. Quote Link to comment Share on other sites More sharing options...
Mchl Posted February 12, 2010 Share Posted February 12, 2010 Your code doesn't make much sense I'm afraid... Something like this? <?php echo '<tr class = "'.(($important == 1) ? 'mainrow1' : 'mainrow'). '">'; ?> Quote Link to comment Share on other sites More sharing options...
bugcoder Posted February 12, 2010 Share Posted February 12, 2010 try like this <?php $class = ($important == 1) ? 'mainrow1' : 'mainrow'; echo '<tr class="$class" >'; ?> Quote Link to comment Share on other sites More sharing options...
runnerjp Posted February 12, 2010 Author Share Posted February 12, 2010 Your code doesn't make much sense I'm afraid... Something like this? <?php echo '<tr class = "'.(($important == 1) ? 'mainrow1' : 'mainrow'). '">'; ?> Worked great thanks.... its just to change colour of <td> dependant on whats selected in db ... thanks ! Quote Link to comment Share on other sites More sharing options...
runnerjp Posted February 12, 2010 Author Share Posted February 12, 2010 Sorry about this but i was trying to use the rule above with this code but seems it dosent like it... <?php echo '<a href=\"index.php?page=message&forum=$forum;&id="'.$getthreads3['postid'].'"">"'.$getthreads3['title'].'"</a>?> Quote Link to comment Share on other sites More sharing options...
jskywalker Posted February 12, 2010 Share Posted February 12, 2010 count the '"' (double quotes) Quote Link to comment Share on other sites More sharing options...
Mchl Posted February 12, 2010 Share Posted February 12, 2010 If you want to expand variables in strings, you need to use double quotes. See this: $var = "Hello!"; echo 'Single quoted $var'; echo "Double quoted $var" ; and for arrays you need {} $arr = array('Hello!'); echo "Double quoted array {$arr[0]}"; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.