user2958236
user2958236

Reputation: 68

Adding echo row inside of include statement

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

Answers (3)

revo
revo

Reputation: 48711

You can:

<?php
    $theme = $rows['theme'].".php";
    include($theme);
?>

But you should validate input if it's coming from user.

Upvotes: 0

Mihai Vilcu
Mihai Vilcu

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

Emil Condrea
Emil Condrea

Reputation: 9963

Simple:

<?php include($rows['theme']); ?>

Upvotes: 1

Related Questions