php help...

F

Fusionhost Group

Any ideas why the last link is not working?

Code:
    <?php
if&#40;empty&#40;$page&#41;&#41; &#123;
		include&#40;'include/news.php'&#41;;
	&#125; else &#123;
	if&#40;$page==home&#41; &#123;
		include&#40;'include/news.php'&#41;;
	&#125; elseif&#40;$page==products&#41; &#123;
		include&#40;'include/products.php'&#41;;
	&#125; elseif&#40;$page==contact&#41; &#123;
		include&#40;'contact.html'&#41;;
	&#125;
&#125;
?>

Is it because I have two elseif's?
note the others work, just the last one...

Thanks :)
 

MichaelG

Free Member
Sep 1, 2005
461
16
Berkshire
Once you have sorted the includes out try this code instead

Code:
<?php

$mypath = "include";

switch &#40;$page&#41; &#123;
case "home"&#58; include "$mypath/news.php"; break;
case "products"&#58; include "$mypath/products.php"; break;
case "contact"&#58; include "contact.html"; break;
default&#58; include "$mypath/news.php";
&#125;

?>

Cleaner and more efficient.
 
Upvote 0
F

Fusionhost Group

Hello,

I have another question.. I cant describe it very well but I will try my best.

I would like to have something similar to this:

Main text
Sub text
Main text
Sub text

Only the main text appears, but once the user clicks the main text it shows the sub text.

I would like to use this to display different bikes I supply for, and then the products available appear.

Any ideas on what it’s called?

Thank you
Jon
 
Upvote 0

Latest Articles

Join UK Business Forums for free business advice