odetron Posted February 11, 2007 Share Posted February 11, 2007 $pg = 1; $_GET[$pg]; //Draws the page data if ($pg == 1) { include("news1.inc.html"); } if ($pg == 2) { include("news2.inc.html"); } what i whant this code to do is change the site content depending on what the url is. like index.php?pg=2 would bring up hello world 2 and just index. php would bring up hello world. but on both i keep getting the one for $pg = 1 why won't this work? Link to comment https://forums.phpfreaks.com/topic/38058-php-include-question/ Share on other sites More sharing options...
Jessica Posted February 11, 2007 Share Posted February 11, 2007 if(isset($_GET['pg']){ $pg = $_GET['pg']; }else{ $pg = 1; } Link to comment https://forums.phpfreaks.com/topic/38058-php-include-question/#findComment-182187 Share on other sites More sharing options...
trq Posted February 11, 2007 Share Posted February 11, 2007 <?php if (isset($_GET['pg'])) { $pg = $_GET['pg']; switch ($pg) { case 1: include "news1.inc.html" ; break; case 2: include "news2.inc.html" ; break; default: include "news1.inc.html" ; break; } } ?> Link to comment https://forums.phpfreaks.com/topic/38058-php-include-question/#findComment-182189 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.