Monkuar Posted February 5, 2012 Share Posted February 5, 2012 I have a option in my profile settings for users to beable to "hide" there friends list this si my code to show there friends on there profile $this->to_print .= <<< LOL <fieldset><legend>$Friends</legend> <div class="padding4"> $Friends2 LOL; while( $r = $DB->fetch_row() ){ if ( $r['last_activity'] > (time() - 900) ) $r['status'] = "<span style=float:right;><span class=desc4><b>Online</b></span></span>"; else $r['status'] = "<span style=float:right;><span class=desc4>Offline</span></span>"; $column++; if ($ibforums->member['settings']['2'] or (!$ibforums->member['id'])){ $color = "{$r['color']}"; $colors = explode(",", $color); if ( strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') ){ { $r['color'] = ($r['color']) ? "style=\"padding:1px 1px 1px 2px;color:#{$colors[0]};filter:Glow(color=#{$colors[1]},strength=3)\"":""; } }else{ $r['color'] = ($r['color']) ? "style=\"color:#{$colors[0]};text-shadow:#{$colors[1]} 2px 1px 1px\"":""; } } $test = explode(";", $info['pdata']); $r['avatar'] = ($r['avatar']) ? "<img src={$r['avatar']} width=64 height=64>" : ""; $r['star'] = ($r['star']) ? "<img class=top3 src=style_images/1/icons/{$r['star']}.png>":""; $r['name'] = "<a href=?i={$r['friendid']}>{$r['name']}{$r['star']}</a>"; $this->to_print .= <<< LOL <dl class="LOL LEFT flm" style="margin-right:5px"><dt2>{$r['name']}</dt2><dd class=padding4>{$r['avatar']}<div class="RIGHT">{$r['status']}</div></dd></dl> LOL; } $this->to_print .= <<< LOL </div> </fieldset> now I will be using this code to make it hidden based on a variable (they set in there settings) //Hide Friends if ($display[0] == "1"){ $friend = ""; }else{ $friend = 'show that function here above code'; } how can I pull all that info into my $friend variable to make it easy? See then I could just echo out $friend and it will show that code above, or not (if they hidden it in settings)? Help ty Link to comment https://forums.phpfreaks.com/topic/256476-how-can-i-put-this-code-into-a-variable/ Share on other sites More sharing options...
Monkuar Posted February 5, 2012 Author Share Posted February 5, 2012 OKay update:I got it into my $friends variable! $friends = $this->to_print .= <<< LOL <fieldset><legend>$Friends</legend> <div class="padding4"> $Friends2 LOL; while( $r = $DB->fetch_row() ){ if ( $r['last_activity'] > (time() - 900) ) $r['status'] = "<span style=float:right;><span class=desc4><b>Online</b></span></span>"; else $r['status'] = "<span style=float:right;><span class=desc4>Offline</span></span>"; $column++; if ($ibforums->member['settings']['2'] or (!$ibforums->member['id'])){ $color = "{$r['color']}"; $colors = explode(",", $color); if ( strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') ){ { $r['color'] = ($r['color']) ? "style=\"padding:1px 1px 1px 2px;color:#{$colors[0]};filter:Glow(color=#{$colors[1]},strength=3)\"":""; } }else{ $r['color'] = ($r['color']) ? "style=\"color:#{$colors[0]};text-shadow:#{$colors[1]} 2px 1px 1px\"":""; } } $test = explode(";", $info['pdata']); $r['avatar'] = ($r['avatar']) ? "<img src={$r['avatar']} width=64 height=64>" : ""; $r['star'] = ($r['star']) ? "<img class=top3 src=style_images/1/icons/{$r['star']}.png>":""; $r['name'] = "<a href=?i={$r['friendid']}>{$r['name']}{$r['star']}</a>"; $this->to_print .= <<< LOL <dl class="LOL LEFT flm" style="margin-right:5px"><dt2>{$r['name']}</dt2><dd class=padding4>{$r['avatar']}<div class="RIGHT">{$r['status']}</div></dd></dl> LOL; } $this->to_print .= <<< LOL </div> </fieldset> LOL; But I can't call my $friends variable anywhere? Link to comment https://forums.phpfreaks.com/topic/256476-how-can-i-put-this-code-into-a-variable/#findComment-1314810 Share on other sites More sharing options...
Monkuar Posted February 5, 2012 Author Share Posted February 5, 2012 HAHAA I FIXED IT!!! TOPIC RESOLVED!!! if ($display[0] == "1"){ $f = ""; }else{ while( $r = $DB->fetch_row() ){ if ( $r['last_activity'] > (time() - 900) ) $r['status'] = "<span style=float:right;><span class=desc4><b>Online</b></span></span>"; else $r['status'] = "<span style=float:right;><span class=desc4>Offline</span></span>"; $column++; if ($ibforums->member['settings']['2'] or (!$ibforums->member['id'])){ $color = "{$r['color']}"; $colors = explode(",", $color); if ( strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') ){ { $r['color'] = ($r['color']) ? "style=\"padding:1px 1px 1px 2px;color:#{$colors[0]};filter:Glow(color=#{$colors[1]},strength=3)\"":""; } }else{ $r['color'] = ($r['color']) ? "style=\"color:#{$colors[0]};text-shadow:#{$colors[1]} 2px 1px 1px\"":""; } } $test = explode(";", $info['pdata']); $r['avatar'] = ($r['avatar']) ? "<img src={$r['avatar']} width=64 height=64>" : ""; $r['star'] = ($r['star']) ? "<img class=top3 src=style_images/1/icons/{$r['star']}.png>":""; $r['name'] = "<a href=?i={$r['friendid']}>{$r['name']}{$r['star']}</a>"; $friendoutput .= <<< LOL <dl class="LOL LEFT flm" style="margin-right:5px"><dt2>{$r['name']}</dt2><dd class=padding4>{$r['avatar']}<div class="RIGHT">{$r['status']}</div></dd></dl> LOL; } $f = '<fieldset><legend>'.$Friends.'</legend> <div class="padding4"> '.$Friends2.' '.$friendoutput.' </div> </fieldset>'; } so epic didn't know .= passes a LOOP! <333333333333333333333333333 Link to comment https://forums.phpfreaks.com/topic/256476-how-can-i-put-this-code-into-a-variable/#findComment-1314827 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.