DBookatay Posted December 12, 2007 Share Posted December 12, 2007 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? Quote Link to comment Share on other sites More sharing options...
DyslexicDog Posted December 12, 2007 Share Posted December 12, 2007 you can use a require to pull the second script into the first script. I use a similar technique to add functionality and keep things simple. Quote Link to comment Share on other sites More sharing options...
DBookatay Posted December 12, 2007 Author Share Posted December 12, 2007 you can use a require to pull the second script into the first script. I use a similar technique to add functionality and keep things simple. How is this accomplished? Quote Link to comment Share on other sites More sharing options...
DyslexicDog Posted December 12, 2007 Share Posted December 12, 2007 <?php if(1==1){ require_once("filename.php"); } ?> The if statement isn't necessary, I typically use a switch statement to decide what files to include. Quote Link to comment Share on other sites More sharing options...
sureshp Posted December 12, 2007 Share Posted December 12, 2007 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. Quote Link to comment Share on other sites More sharing options...
DBookatay Posted December 12, 2007 Author Share Posted December 12, 2007 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 Quote Link to comment Share on other sites More sharing options...
sureshp Posted December 12, 2007 Share Posted December 12, 2007 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>';} ?> Quote Link to comment Share on other sites More sharing options...
DBookatay Posted December 12, 2007 Author Share Posted December 12, 2007 Thats it.... Thank you!!! 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.