Jump to content

[SOLVED] Help with putting a php script inside another php script...


Recommended Posts

I am in the middle of revamping my current site, add have a question about putting a current script into an existing php script...

Heres what I mean:

 

The current script:

<?php
for($x=0; $x<count($features);$x++) {
	if($x%2==0){
		echo"
		<table width=\"100%\">
		<tr>
		";
	}

	echo "<td class=\"vehFtrs\"><img src=\"images/Common/KBB/bulletOn.gif\" /> {$features[$x]}</td>";
	if($x%2==1){
		echo "</tr></table>";
	} 
}
if($x%2==1) {
	echo "<td> </td></tr></table>";
}
?>

 

What I am trying to now do is relocate it into this script:

<?
if ($kbbPrice) {
	$kbb = '
		<div align="center">
		<table>
			<tr><td><img src="images/Common/KBB/hdrL.gif" width="9" height="73" /><a href="http://www.kbb.com/KBB/UsedCars/'.$kbbValue.'" target="_blank"><img src="images/Common/KBB/hdrM.gif" width="153" height="73" /></a><img src="images/Common/KBB/hdrR.gif" width="204" height="73" /></td></tr>
			<tr><td class="ContHldr" align="center"><img src="images/Common/KBB/hdr01.gif" /></td></tr>
		</table>
		<table class="KBB2" width="345">
			<tr>
				<td>
					<div id="KBB1">
					<table>
						<tr class="KBB2"><td class="txt2" colspan="3">Selected Equipment</td></tr>
						<tr><td height="30" width="345" colspan="3"><b>Standard</b></td></tr>
						************ INSERT NEW CODE HERE ************
					</table>
					</div>
					<div id="KBB2" align="left">* Connecticut '.$today.'</div>
				</td>
			</tr>
			<tr><td><img src="images/Default/Titles/btm365.gif" /></td></tr>
		</table>
	</div><p>';}
?>

 

How can this be done?

Im not sure, your code will work on all browsers. Because, you are placing the data generated by the first file (<table>...</table>) into the second file after </tr>. so, in most of the browsers the data will not be shown if they are placed in non-data area. It should be placed after the table closed or between <td></td> tags.

Im not sure, your code will work on all browsers. Because, you are placing the data generated by the first file (<table>...</table>) into the second file after </tr>. so, in most of the browsers the data will not be shown if they are placed in non-data area. It should be placed after the table closed or between <td></td> tags.

 

 

The html code isnt complete, so ignore that.

I didnt bother to check it, wanted to wait till I finished everything..

 

Do you have any ideas for the php question I posed? I would really rather not use an include file

Try this:

======

 

<?php

 

 

if ($kbbPrice) {

 

$features_list = "";

 

for($x=0; $x<count($features);$x++) {

if($x%2==0){

$features_list .= "

<table width=\"100%\">

<tr>

";

}

 

$features_list .= "<td class=\"vehFtrs\"><img src=\"images/Common/KBB/bulletOn.gif\" /> {$features[$x]}</td>";

if($x%2==1){

$features_list .= "</tr></table>";

}

}

if($x%2==1) {

$features_list .= "<td> </td></tr></table>";

}

 

 

 

$kbb = '

<div align="center">

<table>

<tr><td><img src="images/Common/KBB/hdrL.gif" width="9" height="73" /><a href="http://www.kbb.com/KBB/UsedCars/'.$kbbValue.'" target="_blank"><img src="images/Common/KBB/hdrM.gif" width="153" height="73" /></a><img src="images/Common/KBB/hdrR.gif" width="204" height="73" /></td></tr>

<tr><td class="ContHldr" align="center"><img src="images/Common/KBB/hdr01.gif" /></td></tr>

</table>

<table class="KBB2" width="345">

<tr>

<td>

<div id="KBB1">

<table>

<tr class="KBB2"><td class="txt2" colspan="3">Selected Equipment</td></tr>

<tr><td height="30" width="345" colspan="3"><b>Standard</b></td></tr>

 

' . $features_list . '

 

</table>

</div>

<div id="KBB2" align="left">* Connecticut '.$today.'</div>

</td>

</tr>

<tr><td><img src="images/Default/Titles/btm365.gif" /></td></tr>

</table>

</div><p>';}

 

?>

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.