php_beginner_83 Posted June 12, 2009 Share Posted June 12, 2009 Hi All I'm trying to create an online photo gallery. I thought I had it working till I opened it today to have a look, I changed one wee line of code last night and now it's not working the way it did. Before the user would click on a city (e.g. San Francisco) and the page causing the problems would open. On this page would be an intro to San Francisco. On the menu bar there is the option for 'Photos'. When the user clicks this then the photo albums of San Francisco are displayed. The section of code causing the problem (I think) is ... <?php // you build an array for the pages you have. $index = array( "main" => $content, "photo" => "DisplayAlbums.php" ); if ( !empty( $_GET["page"] ) ) { $page = $_GET["page"]; } if ($page = "photo") { $place = isSet( $getValue ) ? $getValue : 'Default'; $page = $_GET["page"]; } if ( array_key_exists( $page , $index ) ) { include( $index[$page] ); } ?> When I take the line, $page = $_GET["page"];, out when the user clicks on the city e.g. San Francisco. Instead of the intro being displayed it goes straight to the photo albums, which previously the user had to click the 'Photo' link on the menu bar to get to it. When I put this line back in again, it works correctly but the value $place isn't filled with the correct value, just 'Default', which I don't want. I need it to be the same as $getValue as I need to use it in another page. $getValue comes from the previous page and changes depending on which link the user has clicked. Can anyone explain why this is happening and what I can do to fix it. Thank you so much. My code in full for this page is ... <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="Content-Language" content="zh"> <?php $getValue = $_GET['place']; ?> <title>My Travel Website</title> <link href="americanStyle.css" rel="stylesheet" type="text/css" media="screen" /> </head> <body> <div id="wrapper"> <div id="americaHeader"> <div id="logo"> <h1><a href="#">My American Adventures</a></h1> </div> </div> <!-- end #header --> <div id="menu"> <ul> <li><a href="#">Home</a></li> <li><?php echo"<a href=America1.php?page=photo>"; ?>Photos</a></li> <li><a href="#">Sights</a></li> <li><a href="#">Dos & Donts</a></li> </ul> </div> <!-- end #menu --> <div id="page"> <div id="content"> <?php if ($getValue == 1) { $content = 'SanFranContent.htm'; } if ($getValue == 2) { $content = 'NewYorkContent.htm'; } if ($getValue == 3) { $content = 'MemphisContent.htm'; } if ($getValue == 4) { $content = 'NashvilleContent.htm'; } // you build an array for the pages you have. $index = array( "main" => $content, "photo" => "DisplayAlbums.php" ); if ( !empty( $_GET["page"] ) ) { $page = $_GET["page"]; } if ($page = "photo") { $place = isSet( $getValue ) ? $getValue : 'Default'; $page = $_GET["page"]; } if ( array_key_exists( $page , $index ) ) { include( $index[$page] ); } ?> </div> </div> </div> </body> </html> Link to comment https://forums.phpfreaks.com/topic/161945-problem-trying-to-get-the-correct-page-to-display/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.