Forum Moderators: coopster

Message Too Old, No Replies

include in an echo statement

code breaking up, please help

         

chrisandsarah

6:37 pm on Nov 8, 2003 (gmt 0)

10+ Year Member



Hi . I'm no php guru, someone else does my php, but i am trying to get a footer menu included in a template using php by using an include code snippet my programmer told me to use.

The trouble is, everytime i paste the php include into the echo statement, it breaks the code up and wont work.
Here is some of the existing code, and the bit i'm trying to get to work:

echo '
<- some existing code here that works ->

<?php include("./Templates/includes/footernav.php");?>

';

If i upload the php include statement up on a blank html page, it produces the desired footer, so i know that part works. Its just when i paste it into an existing php file it breaks the existing code up.
Please help

RonPK

8:51 pm on Nov 8, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Chris, Sarah, remove PHP's open and close tags (<?php and?> ).

chrisandsarah

11:01 pm on Nov 8, 2003 (gmt 0)

10+ Year Member



hi. thanks but i already tried that.
the result is it prints the code on the screen where the footer nav is meant to appear.
e.g
include("./Templates/includes/footernav.php");

Is it because the code snippet i'm using is in an echo ' '; statement?
the trouble is thats where i need it to go, cause the echo contains the <td> cell i need the footernav to be in.

many thanks

coopster

12:17 am on Nov 10, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



You'll have to "stop" and "start" your existing echo statement then. If you currently have something like:

echo '<table><tr><td>some info here</td><td>more info here</td></tr></table>';

and you want your included information in the second <td>, you would change your code as follows:

echo '<table><tr><td>some info here</td><td>';
include("./Templates/includes/footernav.php");
echo '</td></tr></table>';