jaikar Posted December 11, 2007 Share Posted December 11, 2007 Hi, i am traped in a problem.. i have a code where i am echoing the html for different conditions. example.. if($i == 1) { $tbcontent .= '<div>new content</div>' } if($i == 2) { $tbcontent .= '<p>hello</p>'; } if($i == 3) { include('newhtml.php'); } echo $tbcontent; now here is the problem. i am concatenating the tbcontent and echoing finally, it has to happen only in that way because all the condtions are in the loop and have to echo finally. now for the 3rd condition, the htmls are from an include file. its a very long html with embedded php. because of the include, the html document structure is change as it echoing befire i echo the tbcontent. another problem is, this iinclude has lot of variable in between like a junk, so if i put this all in a function, then i have to set all the variables as global where i am sure there will be alot of confusion. what i wanted is, i want this included html to be echoed while i echo the tbcontent in sequence. please advise.. Thanks ! Quote Link to comment Share on other sites More sharing options...
marcus Posted December 11, 2007 Share Posted December 11, 2007 echo tbcontent before inclusion. Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted December 11, 2007 Share Posted December 11, 2007 You could also look into output buffers: ob_start(); include('file.php'); $tbcontent .= ob_get_contents(); ob_end_clean(); Quote Link to comment Share on other sites More sharing options...
jaikar Posted December 11, 2007 Author Share Posted December 11, 2007 not actually working, am i making any wrong? while($result=mysql_fetch_assoc($query)) { $tab_name = ucfirst($result['tab_name']); $selected = ''; if($result['selected'] == 1) { $selected = 'class="selected"'; } if($result['type'] == 1) { $form = new form($result['table_name'], $result['fgroup_id'], $result['fgroup_name'], '{auto_insert:0, auto_responce:1}'); $tcontent = '<div class="tabcontent" id="tab_'.$result['tab_id'].'">'; $tcontent .= $form->print_form; $tcontent .= '</div>'; } //echo $tcontent; if($result['integrate_uploader'] == 1) { $tcontent .= '<div class="tabcontent" id="tab_'.$result['tab_id'].'_uploader">'; ob_start(); include(INCLUDE_PATH.'function.uploader_form.inc.php'); $tcontent .= ob_get_contents(); ob_end_clean(); $tcontent .= '</div>'; //echo $tcontent; } } echoing tbcontent before including also wont work as, there is a dynamic menu that gets generated, so if i echo anything, it will change the complete document model. for now i have only one way, because of this there has to be 2 while loops, and thats working, but 2 while is not necessary if there is a solution to hold the html of included file inside a variable. any suggestions are very much appreciated !! Thanks ! 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.