blesseld Posted August 14, 2009 Share Posted August 14, 2009 Her All, Here is my scenario, <? if ( $page_id == "4" ) { ?> <div id="our-services-box"></div> <? } else { ?> <? } ?> Im using that obviously to display a Div. However I would like to place something in that Div per say like in a variable. I know if i say <?php $title = "Input this title"; ?> then in my html <title><?=$title?></title> I know that works and you can put some html in there, but how can i put a full HTML table in my Div? WITHOUT using an include. I don't want a separate file just for the table. I am already using this page as an include, and would like to keep all of the content in the same file... Any ideas? thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/170299-need-help-placing-multipple-lines-insimple-question/ Share on other sites More sharing options...
DEVILofDARKNESS Posted August 14, 2009 Share Posted August 14, 2009 <?php if ( $page_id == "4" ) { ?> <div id="our-services-box"> <table> <tr><td><?php echo "FIRST ROW"; ?></td></tr> <tr><td><?php echo "SECOND ROW"; ?></td></tr> </table> </div> <?php } else { ?> <?php } ?> ??? P.S.: it's <title><?php echo $title; ?></title> Quote Link to comment https://forums.phpfreaks.com/topic/170299-need-help-placing-multipple-lines-insimple-question/#findComment-898355 Share on other sites More sharing options...
mikesta707 Posted August 14, 2009 Share Posted August 14, 2009 just write a table in there? <? if ( $page_id == "4" ) { ?> <div id="our-services-box"><table><tr><td>I'm a table!</td></tr></table></div> <? } else { ?> <? } ?> Quote Link to comment https://forums.phpfreaks.com/topic/170299-need-help-placing-multipple-lines-insimple-question/#findComment-898357 Share on other sites More sharing options...
blesseld Posted August 14, 2009 Author Share Posted August 14, 2009 Hey, Thanks for the reply, not quite what i am going for... let me post the full info. This is my Services page. <?php $sheet_name = "ourservices"; include("inc/control.php"); ?> <?php include("inc/page-top.php"); ?> <h2 class="<?=$h2_class?>"><?=$main_h2?></h2> <div id="services-chart"> <table class="alternating" cellpadding="0" cellspacing="0" border="0" width="755"> <tr> <th class="cell1" align="center"> </th> <th class="cell2" align="center">Free</th> <th class="cell3" align="center">Bronze</th> <th class="cell4" align="center">Silver</th> <th class="cell5" align="center">Gold</th> <th class="cell6" align="center">Custom</th> </tr> <tbody> <tr> <td class="cell1" align="left"><p class="t1">test</p></td> <td class="cell2" align="left"><p class="t2">test</p></td> <td class="cell3" align="center">test</td> <td class="cell4" align="center">test</td> <td class="cell5" align="center">test</td> <td class="cell6" align="center"><a href="#nogo">test</a></td> </tr> <tr> <td class="cell1" align="left"><p class="t1">test</p></td> <td class="cell2" align="left"><p class="t2">test</p></td> <td class="cell3" align="center">test</td> <td class="cell4" align="center">test</td> <td class="cell5" align="center">test</td> <td class="cell6" align="center"><a href="#nogo">test</a></td> </tr> <tr> <td class="cell1" align="left"><p class="t1">test</p></td> <td class="cell2" align="left"><p class="t2">test</p></td> <td class="cell3" align="center">test</td> <td class="cell4" align="center">test</td> <td class="cell5" align="center">test</td> <td class="cell6" align="center"><a href="#nogo">test</a></td> </tr> <tr> <td class="cell1" align="left"><p class="t1">test</p></td> <td class="cell2" align="left"><p class="t2">test</p></td> <td class="cell3" align="center">test</td> <td class="cell4" align="center">test</td> <td class="cell5" align="center">test</td> <td class="cell6" align="center"><a href="#nogo">test</a></td> </tr> <tr> <td class="cell1" align="left"><p class="t1">test</p></td> <td class="cell2" align="left"><p class="t2">test</p></td> <td class="cell3" align="center">test</td> <td class="cell4" align="center">test</td> <td class="cell5" align="center">test</td> <td class="cell6" align="center"><a href="#nogo">test</a></td> </tr> <tr> <td class="cell1" align="left"><p class="t1">test</p></td> <td class="cell2" align="left"><p class="t2">test</p></td> <td class="cell3" align="center">test</td> <td class="cell4" align="center">test</td> <td class="cell5" align="center">test</td> <td class="cell6" align="center"><a href="#nogo">test</a></td> </tr> </tbody> </table> </div> <?php $our_services_right_column = "<h2>This is a test</h2><p>this is test thisx is testing somthing different then just a heading to see if everything is working ok.</p>"; ?> <?php include("inc/page-bot.php"); ?> I would like to wrap the table in somthing so i can call it within: <? if ( $page_id == "4" ) { ?> <div id="our-services-box">[color=red]CALL THE TABLE HERE[/color]</div> <? } else { ?> <? } ?> So without writing the table in... i want to call it from within anther file... is that possible? again without cutting the table out and placing it in a separate file then using an include... i have a million includes already and would like to keep the content per page in the same file. sorry for any confusion Quote Link to comment https://forums.phpfreaks.com/topic/170299-need-help-placing-multipple-lines-insimple-question/#findComment-898364 Share on other sites More sharing options...
mikesta707 Posted August 14, 2009 Share Posted August 14, 2009 you can save the file's HTML as a variable, and use the javascript innerHTML method to put the table inside the DIV. but i'm afraid I don't really understand what you want to do Quote Link to comment https://forums.phpfreaks.com/topic/170299-need-help-placing-multipple-lines-insimple-question/#findComment-898382 Share on other sites More sharing options...
blesseld Posted August 15, 2009 Author Share Posted August 15, 2009 Here is what I have done, its exactly what i want to do, however my question now is, Is there a smarter way to do this? Ok, So i created a string <?php //Start Service Table $service_table = '<div id="services-chart">'; $service_table .= '<table class="alternating" cellpadding="0" cellspacing="0" border="0" width="755">'; $service_table .= '<tr>'; $service_table .= '<th class="cell1" align="center"> </th>'; $service_table .= '<th class="cell2" align="center">Free</th>'; $service_table .= '<th class="cell3" align="center">Bronze</th>'; $service_table .= '<th class="cell4" align="center">Silver</th>'; $service_table .= '<th class="cell5" align="center">Gold</th>'; $service_table .= '<th class="cell6" align="center">Custom</th>'; $service_table .= '</tr>'; $service_table .= '<tbody>'; $service_table .= '<tr>'; $service_table .= '<td class="cell1" align="left"><p class="t1">test</p></td>'; $service_table .= '<td class="cell2" align="left"><p class="t2">test</p></td>'; $service_table .= '<td class="cell3" align="center">test</td>'; $service_table .= '<td class="cell4" align="center">test</td>'; $service_table .= '<td class="cell5" align="center">test</td>'; $service_table .= '<td class="cell6" align="center"><a href="#nogo">test</a></td>'; $service_table .= '</tr>'; $service_table .= '<tr>'; $service_table .= '<td class="cell1" align="left"><p class="t1">test</p></td>'; $service_table .= '<td class="cell2" align="left"><p class="t2">test</p></td>'; $service_table .= '<td class="cell3" align="center">test</td>'; $service_table .= '<td class="cell4" align="center">test</td>'; $service_table .= '<td class="cell5" align="center">test</td>'; $service_table .= '<td class="cell6" align="center"><a href="#nogo">test</a></td>'; $service_table .= '</tr>'; $service_table .= '<tr>'; $service_table .= '<td class="cell1" align="left"><p class="t1">test</p></td>'; $service_table .= '<td class="cell2" align="left"><p class="t2">test</p></td>'; $service_table .= '<td class="cell3" align="center">test</td>'; $service_table .= '<td class="cell4" align="center">test</td>'; $service_table .= '<td class="cell5" align="center">test</td>'; $service_table .= '<td class="cell6" align="center"><a href="#nogo">test</a></td>'; $service_table .= '</tr>'; $service_table .= '<tr>'; $service_table .= '<td class="cell1" align="left"><p class="t1">test</p></td>'; $service_table .= '<td class="cell2" align="left"><p class="t2">test</p></td>'; $service_table .= '<td class="cell3" align="center">test</td>'; $service_table .= '<td class="cell4" align="center">test</td>'; $service_table .= '<td class="cell5" align="center">test</td>'; $service_table .= '<td class="cell6" align="center"><a href="#nogo">test</a></td>'; $service_table .= '</tr>'; $service_table .= '<tr>'; $service_table .= '<td class="cell1" align="left"><p class="t1">test</p></td>'; $service_table .= '<td class="cell2" align="left"><p class="t2">test</p></td>'; $service_table .= '<td class="cell3" align="center">test</td>'; $service_table .= '<td class="cell4" align="center">test</td>'; $service_table .= '<td class="cell5" align="center">test</td>'; $service_table .= '<td class="cell6" align="center"><a href="#nogo">test</a></td>'; $service_table .= '</tr>'; $service_table .= '<tr>'; $service_table .= '<td class="cell1" align="left"><p class="t1">test</p></td>'; $service_table .= '<td class="cell2" align="left"><p class="t2">test</p></td>'; $service_table .= '<td class="cell3" align="center">test</td>'; $service_table .= '<td class="cell4" align="center">test</td>'; $service_table .= '<td class="cell5" align="center">test</td>'; $service_table .= '<td class="cell6" align="center"><a href="#nogo">test</a></td>'; $service_table .= '</tr>'; $service_table .= '</tbody>'; $service_table .= '</table>'; $service_table .= '</div>'; //End Service Table ?> Now this is a table that only appears on my service page, however also on the service page the layout changes. so the whole purpose of this is to have the table info above in the same file as the content(paragraphs photos etc.) that way I don't need a separate file to include the table. Then in my main file for the template of the site, I use an if statement and then call my table. <?php if ( $page_id == "4" ) { ?> <div id="our-services-box"><?php echo $service_table; ?></div> <? } else { ?> <? } ?> now when i view service page, the table shows up. And i can edit it form the same file as my content. Is this a good approach, or is there a way smarter way? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/170299-need-help-placing-multipple-lines-insimple-question/#findComment-899018 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.