Jump to content

i cannot figure this out..


newguy2010

Recommended Posts

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

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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
}
?>

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.