Jump to content

Need help Placing Multipple lines in...(simple question)


Recommended Posts

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.

 

 

<?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>

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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.