newguy2010 Posted February 15, 2011 Share Posted February 15, 2011 i was wondering how i would go about making a single page that would have sections on it and if you click a section the page reloads and shows the information that is within that section? i got my code to show both the section and its information at the same time but cannot figure out how to do the above. please help. thank you -Adam Quote Link to comment https://forums.phpfreaks.com/topic/227796-i-cannot-figure-this-out/ Share on other sites More sharing options...
AbraCadaver Posted February 15, 2011 Share Posted February 15, 2011 Something like: sections.php <a href="sections.php?id=1">Section 1</a> <a href="sections.php?id=2">Section 2</a> <a href="sections.php?id=3">Section 3</a> <?php if(isset($_GET['id']) && file_exists('section' . (int)$_GET['id'] . '.html')) { include('section' . (int)$_GET['id'] . '.html'); } ?> Then you would have section1.html, section2.html, section3..html. Several other ways to do it. Quote Link to comment https://forums.phpfreaks.com/topic/227796-i-cannot-figure-this-out/#findComment-1174692 Share on other sites More sharing options...
newguy2010 Posted February 15, 2011 Author Share Posted February 15, 2011 i have a database set up and i am trying to make it where i dont have to make abunch of pages, but is there a way to make it where i have a page for the sections and a page for the information? or would i have to make a page for the information within each section? thank you -Adam Quote Link to comment https://forums.phpfreaks.com/topic/227796-i-cannot-figure-this-out/#findComment-1174696 Share on other sites More sharing options...
AbraCadaver Posted February 15, 2011 Share Posted February 15, 2011 Your original question was vague but there are several ways whether you want one page or more. This example is just like my previous one but insert your database query: <a href="sections.php?id=1">Section 1</a> <a href="sections.php?id=2">Section 2</a> <a href="sections.php?id=3">Section 3</a> <?php if(isset($_GET['id'])) { $query = 'SELECT * FROM sections WHERE id = ' . (int)$_GET['id']; //retrieve data from query //echo section stuff from query } ?> Quote Link to comment https://forums.phpfreaks.com/topic/227796-i-cannot-figure-this-out/#findComment-1174701 Share on other sites More sharing options...
newguy2010 Posted February 15, 2011 Author Share Posted February 15, 2011 ok ill give it a try. how would i go about making this dynamic? <a href="sections.php?id=1">Section 1</a> <a href="sections.php?id=2">Section 2</a> <a href="sections.php?id=3">Section 3</a> would i do it like this, calling the database and use '$sectionid = id' and '$sectionname = Section'? echo "<a href=\sections.php?id=" . $sectionid . ">$sectionname</a>"; thank you -Adam Quote Link to comment https://forums.phpfreaks.com/topic/227796-i-cannot-figure-this-out/#findComment-1174704 Share on other sites More sharing options...
newguy2010 Posted February 15, 2011 Author Share Posted February 15, 2011 ok i have tried and i cannot get it to work this is what i got. im sure its something simple plz help. <?php $bookmarksections = mysql_query("SELECT * FROM bookmarksections"); confirm_query($bookmarksections); while ($bookmarksection = mysql_fetch_array($bookmarksections)){ $bookmarks = mysql_query("SELECT * FROM bookmarks WHERE SectionID = {$bookmarksection["ID"]}"); confirm_query($bookmarks); $count = mysql_num_rows($bookmarks); echo "<li>"; if ($count > 0){ $url = urlencode($bookmarksection["SectionName"]); echo "<a href=\"Bookmarks.php?section=".$url."\">"; } echo "<span class=\"name\">{$bookmarksection["SectionName"]}</span>"; echo "<span class=\"arrow\"></span>"; echo "<span class=\"graytitle\">$count</span>"; echo "</a>"; echo "</li>"; if(isset($_GET['SectionName'])){ while($bookmarklist = mysql_fetch_array($bookmarks)){ $title = $bookmarklist["KindofBookmark"]; if ($title != NULL){ echo "<li class=\"title\">". $title ."</li>"; echo "<li><a href=\"{$bookmarklist["BookmarkLink"]}\">"; echo "<span class=\"name\">{$bookmarklist["Bookmark"]}</span>"; echo "<span class=\"arrow\"></span></a></li>"; } } } } ?> thank you -Adam Quote Link to comment https://forums.phpfreaks.com/topic/227796-i-cannot-figure-this-out/#findComment-1174717 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.