Jump to content

[SOLVED] Multiple "id's" in URL?


kagedwebdesign

Recommended Posts

Hey guys!

 

I was using a java/text dropdown menu, but now the people would like to use a seprate section for links  I have it set up now using two seprate php codes that are identical except for the id codes...the one for the main content is ?id the other is ?links for, you guessed it, the links.

 

All works well...but the problem I'm running into is once you click somewhere and get to a page w/ ?id (ex. index.php?id=example) and try to load the menu bar, it takes you back to the main page...  :wtf:

 

Is there any way I can set the code to detect what ?id page I'm on, load that into the URL and then add in the ?links?

 

When I go the page using ?id=example&links=examplelinkpage it works without issue...but that would defeat the reason I'm doing it this way...having to go back through and change all of the links and make multiple duplicates just so that I can do the links...

 

Currently, the php codes for both sections are as follows...

 

CODE FOR THE LINKS BOX:

<?php
  if ($_GET["links"])
  {
    if (file_exists($_GET["links"] . ".php"))
    {
      include($_GET["links"] . ".php");
    }
    else
    {
      include("Please Try Again");
    }
  }
  else
  {
    include("linksmain.php");
  }
?>

 

CODE FOR THE CONTENT AREA:

 
<?php
  if ($_GET["id"])
  {
    if (file_exists($_GET["id"] . ".php"))
    {
      include($_GET["id"] . ".php");
    }
    else
    {
      include("error.php");
    }
  }
  else
  {
    include("main.php");
  }
?>

 

 

Currently, the code for the place where you select the parent links which open up the child links (the code above) is located here...

 

<span class="style1"><a href="index.php" class="nav">   >>Home</a><br />

   <a href="?links=firmlinks" class="nav">>>Firm Overview</a><br />
	 </span>                                           
        
          <span class="style1">   <a href="?links=attorneyslink" class="nav" >>>Attorneys</a><br />
          </span>
          
          <span class="style1">   <a href="?links=ssdlinks" class="nav">>>Social Security Disability</a><br />                                                
          </span>
         
          <span class="style1">   <a href="?links=contactlinks" class="nav">>>Contact Us</a></span><br />			

 

 

Any help would be greatly appreciated...If you need more informaton, just let me know!!

 

 

Thanks

 

Kyle

Kaged Web Design

Link to comment
Share on other sites

Use

 

if(isset($_GET['ID']))
{
switch($ID)
{
//Stuff
}
}

 

To see which ID your on, then have a string $URL that changes on each case, then use $URL.="&link=" . $_GET['link']; then use header("Loaction: " . $URL);

 

Just off the top of my head, but I'm tired, so don't take my thing as set in stone

Link to comment
Share on other sites

I'm thoroughly confused - why would you need to make multiple copies of anything if you used both id and links in the get string?  Can't you just make one script which include a links file and a main file?

 

I was saying I'd haveto make multiple copies if I couldn'tget this to work....and thats what I'm trying to figure out...

 

Use

 

if(isset($_GET['ID']))
{
switch($ID)
{
//Stuff
}
}

 

To see which ID your on, then have a string $URL that changes on each case, then use $URL.="&link=" . $_GET['link']; then use header("Loaction: " . $URL);

 

Just off the top of my head, but I'm tired, so don't take my thing as set in stone

 

could youexplain a little bit more? I'm still new to PHP...:)

Link to comment
Share on other sites

Ok, look at my code above, then look at this page

 

http://www.w3schools.com/PHP/php_switch.asp

 

That'll teach you what I mean with the switch.

 

Then, for each $ID value, make $URL = "Whateveryou want your url to be for that ID";

 

Then, after the switch code, put $URL .= "?links=" $_GET['links'];

or

$URL .= "&links=" . $_GET['links'];

 

if $URL already has some GET vars in it. Then just

 

header("Location: " . $URL);

 

Sorry, I can't explain it any more simply than that

Link to comment
Share on other sites

I'm not sure he needs a switch - he's using the value of the id argument to include a named file (which is risky from a security viewpoint actually, but that's another issue).

 

For the original issue, I don't see any need to duplicate anything.  Both the id and link arguments can be passed through any url and through to any script, and then they can be used to decide what to do.  They can also be accessed from inside the included files.

Link to comment
Share on other sites

I'm not sure he needs a switch - he's using the value of the id argument to include a named file (which is risky from a security viewpoint actually, but that's another issue).

 

For the original issue, I don't see any need to duplicate anything.  Both the id and link arguments can be passed through any url and through to any script, and then they can be used to decide what to do.  They can also be accessed from inside the included files.

 

All I want to do is make it so that I do not have to change the links on each individual page...but I'm not sure how to set it so that when the links section loads, it doesn't take it back to the home php file...so say i'm on the application.php page and i click on the lawyers link, I want the application.php to show at the bottom, but the lawyerslinks.php file to load in the top section...

 

It might help if you see the site...

 

www.damichigan.com/development

 

thanks guys!

 

Kyle

Link to comment
Share on other sites

What if you do something like this:

 

<span class="style1">   <a href="?id=<?php echo $id; ?>&links=attorneyslink" class="nav" >>>Attorneys</a><br />

 

Then when you click the link id will be preserved, and links will be set.  Similarly for links which change the id, you can pass along links as a variable.

Link to comment
Share on other sites

What if you do something like this:

 

<span class="style1">   <a href="?id=<?php echo $id; ?>&links=attorneyslink" class="nav" >>>Attorneys</a><br />

 

Then when you click the link id will be preserved, and links will be set.  Similarly for links which change the id, you can pass along links as a variable.

 

That makes a whole lot of sense...I'm working on editing the PHP code to get it to send the "$id" tag out, so that when i tell the PHP to load it, it works.  But as is, it works how it should...I'm just hoping that once I get it to send/savethe $id variable, it will work...

 

Thanks for all your help! (P.S. Any assistnce on sending the variablewould be great too :) )

 

Kyle

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.