Hello all,
I have a select drop down, and a value is passed.
based on that value, I do a php include $value.html.
It doesn't work, any idea why?
PHP:
--------------------------------------------------------------------------------
<form name="dwnld" action="./inst.php" method="POST">
<select name="brandSelect" onChange="submit()">
<option selected>Select a brand ----------</option>
<option value="1">1™</option>
<option value="2">2option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
</form>
<?php include('./folder/$brandSelect.html') ?>
--------------------------------------------------------------------------------
The include doesn't work, yes I am doing a $_POST, but still, it doesn't get included.
The include is on the same page as the form, it's a postback.
File paths are all fine
yes, 1.html, 2.html are the pages to include
I tried this: <?php if(isset($brandSelect)) include 'folder/' . $brandSelect . '.html' ; ?> Still doesn't work!
Any idea why?
Thanks
include doesn't work..
Moderator: General Moderators
-
Klaws_wolverine
- Forum Commoner
- Posts: 32
- Joined: Mon Sep 29, 2003 10:11 am
- mrvanjohnson
- Forum Contributor
- Posts: 137
- Joined: Wed May 28, 2003 11:38 am
- Location: San Diego, CA
I think if you are going to use a variable in line you need to use double quotes.
Otherwise you are literally requesting for the page $brandSelect.html.
You might want to
just to make sure it's getting set to what it should be getting set to.
Code: Select all
<?php
include("./folder/$brandSelect.html")
?>You might want to
Code: Select all
<?php
echo $brandSelect
?>You need to make a change to your include statement.
Either do what mrvanjohnson said (change your original to double-quoted), or use something similar to what you have in your second example.
The reason that didn't work in your if statement is that you didn't tell the if statement what to do. It should have been this:
Either do what mrvanjohnson said (change your original to double-quoted), or use something similar to what you have in your second example.
Code: Select all
<?php
//Change
include('./folder/$brandSelect.html');
//To
include('folder/' . $brandSelect . '.html');
?>Code: Select all
<?php
if (isset($brandSelect)) { //Dont forget the {
include 'folder/' . $brandSelect . '.html';
} //Dont forget the }
?>