Web Hosting Talk







View Full Version : echoing a row within php include


FG-alex
12-03-2007, 08:30 PM
Hello, I have a template for pages but use a separate page for the 'content'. At the moment I have:



<?php echo $row_page['pagetitle']; ?>
<?php include('inc/header.php'); ?>
<?php include(''page-.php"); ?>
<?php include('inc/footer.php'); ?>

What I need to have is:


<?php include('page-''echo $row_page['pageid']''.php' ?>
But no matter what I do I cannot get this code to work, it will only accept 'page-1.php' but not a dynamic value.

Is there a way to get around this?


Thanks.

Tom P
12-03-2007, 08:36 PM
Hello,

It's not working because of the way you are trying to make it work. The style you have used is if you are executing the PHP which would require backticks but that's normally only for shell execution.

Here is the fixed code:

<?php include('page-' . $row_page['pageid'] . '.php' ?>

Enjoy!

FG-alex
12-03-2007, 09:08 PM
Thanks. That saves me a lot of time. I just had to add the ); and got it working perfectly.

Tom P
12-03-2007, 09:12 PM
Wow, you're right.. I missed the closing bracket!

Your welcome though! :)