dezkit Posted February 24, 2008 Share Posted February 24, 2008 Is there a code so if the page is index.php?page=Home it says Hi and if the page is index.php?page=Events it says Hello, or something like that, but the code HAS to be in index.php. Lots of Thanks. im not that pro in PHP but i think the code has to look something like <?php $?=?("?"); if ($?=="index.php?page=Home") echo "Hi"; elseif ($d=="index.php?page=Events") echo "Hello"; ?> Link to comment https://forums.phpfreaks.com/topic/92752-need-help/ Share on other sites More sharing options...
tippy_102 Posted February 24, 2008 Share Posted February 24, 2008 You could use Switch statements for that http://ca.php.net/switch Link to comment https://forums.phpfreaks.com/topic/92752-need-help/#findComment-475203 Share on other sites More sharing options...
Bauer418 Posted February 24, 2008 Share Posted February 24, 2008 <?php $page = strtolower($_GET['page']); switch ($page) { case 'home': print 'Hi'; break; case 'events': print 'Hello'; break; } ?> Link to comment https://forums.phpfreaks.com/topic/92752-need-help/#findComment-475205 Share on other sites More sharing options...
dezkit Posted February 24, 2008 Author Share Posted February 24, 2008 THANK YOU VERY MUCH BAUER!!!! :-* :-* :-* Link to comment https://forums.phpfreaks.com/topic/92752-need-help/#findComment-475209 Share on other sites More sharing options...
dezkit Posted February 25, 2008 Author Share Posted February 25, 2008 btw i want both the default page, index.php, and index.php?view=Home to say Home <?php $page = strtolower($_GET['page']); switch ($page) { case 'home': print 'Home'; break; case 'events': print 'Events'; break; case 'employment': print 'Employment'; break; case 'gallery': print 'Gallery'; break; case 'djs': print 'DJs'; break; case 'vip': print 'VIP'; break; case 'forum': print 'Forum'; break; case 'contact': print 'Contact'; break; } ?> Link to comment https://forums.phpfreaks.com/topic/92752-need-help/#findComment-475437 Share on other sites More sharing options...
dezkit Posted February 25, 2008 Author Share Posted February 25, 2008 problem solved. i just added an additional case '': print 'Home'; break; Link to comment https://forums.phpfreaks.com/topic/92752-need-help/#findComment-475442 Share on other sites More sharing options...
Lamez Posted February 25, 2008 Share Posted February 25, 2008 try this <?php $getlink = $_GET["link"]; if ($getlink == "page1") { echo "Hello This Is Page 1"; } elseif ($getlink == "page2") { echo "Welcome To Page 2"; } else { echo "Ooops! Page Not Found"; } ?> so its like ?link=page1 and the out put is "hello this is page 1" Link to comment https://forums.phpfreaks.com/topic/92752-need-help/#findComment-475443 Share on other sites More sharing options...
dezkit Posted February 25, 2008 Author Share Posted February 25, 2008 I got it, i don't need that code, thanks for the quick reply though Link to comment https://forums.phpfreaks.com/topic/92752-need-help/#findComment-475446 Share on other sites More sharing options...
Lamez Posted February 25, 2008 Share Posted February 25, 2008 lol oh np Link to comment https://forums.phpfreaks.com/topic/92752-need-help/#findComment-475448 Share on other sites More sharing options...
Bauer418 Posted February 25, 2008 Share Posted February 25, 2008 Instead of using "case '':" try using "default:" That will run the specified action in the case that none of the other switches are met, even if the string isn't blank. Link to comment https://forums.phpfreaks.com/topic/92752-need-help/#findComment-475449 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.