bruce1980 Posted March 14, 2013 Share Posted March 14, 2013 (edited) Hi New to the forum (introduction in the intro section) so please be gentle! I've started using PHP includes in my site but need to pull some data from my database to create the code for the include... Heres the include... <?php include '../includes/Folder/FileName.php'; ?> But instead of hard coding "FileName", I want to pull the filename from my database. Ive been using.... ?php foreach($data as $row){echo $row['ref_filename'];}?> ...to pull the filename into other places in the page but cant figure out how to get the PHP Filename code into the PHP Include code without breaking it! 've tried things like... <?php "include '../includes/Folder/'"foreach($data as $row){echo $row['ref_filename']".php";}?> But, being a complete PHP novice, I cant get it working! Anyone spot the obvious mistake? Cheers, Bruce! Edited March 14, 2013 by bruce1980 Quote Link to comment https://forums.phpfreaks.com/topic/275667-probably-a-very-simple-markup-query/ Share on other sites More sharing options...
Solution salathe Posted March 14, 2013 Solution Share Posted March 14, 2013 The basic idea is something like: foreach ($data as $row) { include '../includes/Folder/' . $row['ref_filename'] . '.php'; }Hope that gets the ball rolling. Quote Link to comment https://forums.phpfreaks.com/topic/275667-probably-a-very-simple-markup-query/#findComment-1418684 Share on other sites More sharing options...
bruce1980 Posted March 14, 2013 Author Share Posted March 14, 2013 You are a superstar! Works first time!! Next time im at Knockhill, I'll buy you a pint! Cheers Badger! Quote Link to comment https://forums.phpfreaks.com/topic/275667-probably-a-very-simple-markup-query/#findComment-1418685 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.