Mulitple HTML files to a single pHp file

Okay… So I’m a HTML/CSS/PHP/MySQL newbie. I’m attempting to “convert”, so to speak, 5 HTML files to 1 PHP file.

I have 1 HTML so far, with a drop down box of 5 choices.

Choice 1 Choice 2 Choice 3 Choice 4 Choice 5
		<input type="submit" value="Go"> </form></body></blockquote>

I have 5 additional HTML files respectively named Choice 1, 2, 3, 4, and 5.

I have 1 PHP file, named “test.php” with the following code:

<?php
		$choice = $_GET['choice'];
		
		if ($choice == 1)
			$value = Choice1.html;
			
		else if ($choice == 2)
			$value = Choice2.html;
			
		else if ($choice == 3)
			$value = Choice3.html;
			
		else if ($choice == 4)
			$value = Choice4.html;
			
		else
			$value = Choice5.html;
	?>
	
	<?php echo($value); ?></blockquote>

Now. I know that the PHP code is wrong. Whenever I click on a choice from the drop down box, the parser is obviously just returning text. I do not want this. I want the code from inside the desired HTML file. I don’t know how to do this.

I would be extremely (and I mean that!) grateful if you could help me out on this. I know its probably something so straight forward but I cannot seem to grasp it…

Looking forward to hearing from you.

Hi there,

Try replacing:
[php]<?php echo($value); ?>[/php]

with:
[php]<?php include $value; ?>[/php]

(providing the html files are in the same directory as this php file)

The html files are in the same directory as the php file (Applications/MAMP/htdocs)
However, your proposed solution does not work for me. :frowning:
I’m not even getting anything back. (i.e. before, I was getting text back. Now, nothing… :frowning: )

Firstly, make sure your strings are surrounded by " or '.

[php] if ($choice == 1)
$value = “Choice1.html”;

	else if ($choice == 2)
		$value = "Choice2.html";

	else if ($choice == 3)
		$value = "Choice3.html";

	else if ($choice == 4)
		$value = "Choice4.html";

	else
		$value = "Choice5.html";

[/php]

You may also want to ensure that your html files definitely have the names specified, and have some visible output.

The double quotes worked.

Thank you. :slight_smile:

Sponsor our Newsletter | Privacy Policy | Terms of Service