Reputation: 68
Can I pull data from mySQL into include statement so it will open whatever URL I place into field "theme"
<?php include("<? echo $rows['theme']; ?>"); ?>
I want to add this to index.php and I have a editable form where I can add any URL to field theme. Can someone help me get this to work?
Upvotes: 0
Views: 55
Reputation: 48711
You can:
<?php
$theme = $rows['theme'].".php";
include($theme);
?>
But you should validate input if it's coming from user.
Upvotes: 0
Reputation: 1967
<?php
// here you are already inside the php tags so you don't need any others
include($rows['theme']); // you don't need to echo anything just pass the value
?>
However i would recommend you use a switch statement to check the value on $rows['theme']
Upvotes: 1