Compound subpages

liunx

Guest
I'm not sure what this is called, but how would I go about making addresses like these:

<!-- m --><a class="postlink" href="http://htmlforums.com/newthread.php?s=&action=newthread&forumid=44">http://htmlforums.com/newthread.php?s=& ... forumid=44</a><!-- m -->

Where it has more than one "q=thing" things? I hope I'm not making this too vague lol, if someone could just tell me what this is called I could ask a more concise question.ummmmmm the link you posted doesnt work...try again and ill see if i can help..those are variables.

so what is it you want to do. all that does is send a variable to the same page or a seperate page. same thing a form does when you send it through GET method.lol - I never understand why people ask "How do I get a link like this: <!-- w --><a class="postlink" href="http://www.example.com?r=test&m=link">www.example.com?r=test&m=link</a><!-- w -->? As if it's some *cool* thing to have. :D

So, my question is. Why do you want a link like that?That link up there was an example lol :|

Ok, say I want to have a page, let's name it ddrmixes.php, and there users can select what mix they want, and they would be pointed to ddrmixes.php?mix=1st, then they can select a song inside that mix, and be pointed to ddrmixes.php?mix=1st&song=midnite see what I'm getting at? I know how to make pages in just the first part, (ddrmixes.php?mix=1st) but I don't know how to go further with the &song=midnite. Is that a little better?

Oh, and I want it to simplify my site structure, that's a pretty good reason isn't it? Screw the "cool" part, I think it'll work lol.well with php you can just add on to it each time.

so you have this

ddrmixes.php

and when they click on something you get this

ddrmixes.php?mix=1 (you don't want the st in there.)

so on that page you you just add to it depening on what they choose

ddrmixes.php?mix=$_GET["mix"]
$_GET["mix"] will = 1 form teh url

that will get the first variable (from the url) they clicked on, then depending one what they click on next you jsut add it to that line above.

and so on and so on. it is pretty easy really.Hmm, yeah it seems simple, but I can't figure it out. I'm completely new to PHP, I don't have any books, any knowledge or anything, all the beginning tutorials tell me to rtfm, but it would take me years to read (and understand it all).

I know you put this script in the ddrmixes.php file:


<?
$requested = $_GET['mix'];
if($requested == "1"){
include ("mixes/1.php");
}
elseif($requested == "2"){
include ("mixes/2.php");
}
?>


but then what do I put in the 1 and 2 files to add onto the ddrmixes.php?mix=1?


ddrmixes.php?mix=$_GET["mix"]


I'm not sure where that fits in...I know it's the address for the mixes, but what about the subpages?

Sorry for being such a n00b again lol, but I really do value all you people's help ^_^well you took a different turn that I had thought. I wouldn't load another page like that.

but if you are then in that 1.php it would load whatever they need to click on again to get to the next screen. since you know what page is being loaded then you don't need the $_GET["mix"] thing as you can hard code it.

so it all depends on what you want to do on the 1.php pages as to what the next variable would be.Hmm...well then...uh oh lol. I asked a question about subpages and people told me to use that script...but now it's bad. If its not too much trouble, could somone tell me how to set this thing up? Like what exactly I put in the ddrmixes.php files and what I put in the 1.php, 2.php, etc files, and possibly what it means? If you could even just tell me what this concept is called I could google it and try to gather more information that way. Thanks.there is really no concept about it. it doesn't matter which way you do it, I wouldn't do it that way, personally.

let me see if I can round up some tutorials. I don't have time to explain how to do it.lol, well by concept i mean "it". I don't know what "it" IS, compound subpages? variables? i have no idea what its even called that I want to do lol.

Thanks for the help so far, thanks for looking for tuts on "it"Well, I don't mean to jump the gun here, scoutt, but I need to figure this out...seriously. Is there anyone out there who can breifly explain how to add more than one variable to URLs? Maybe a link to a tut, or a "you put this [script] in this file, and hten you put this [script] into this file, and here's what the hell is going on."Let me understand this.

You want a user to be able to select a mix and then a song title, correct?

Tell me:

1) How does the user get to select the mix and then the song? Are you presenting them with a html form they complete?
2) Why are you so keen on the ?mix=1&song=title? This has nothing to do with the solution other than it might be a byproduct of it. I would say concentrate on developing the functionality to allow the user to select what it is they have to select, and if that results in the variables being passed by HTTP GET (the method you reference) then so be it.

If you have the forms the user interacts with then post them here and we'll help with the PHP code (please remember to use the forum's
Code:
 tags when posting code).well I have searched more than 140 tutorials and don't see any that could help in the way you want. I believe it is going to boil down to somebody writing it for you and telling you what needs to be done. also this will depend on what you are trying to do?

like I said it is not hard to add variables to the url, just getting the process of what you want to do is the question.

now I don't have the time to do this but maybe somebody on here can. maybe torent might have an idea or a tutorial. let me ask him.Welp, here's what I'm trying to, basically exactly the same set up as this page:

<!-- m --><a class="postlink" href="http://www.angelroms.com/emulators-Download">http://www.angelroms.com/emulators-Download</a><!-- m --> .php

from there you can choose a system from just a simple list of links, and then the url would become

<!-- m --><a class="postlink" href="http://www.angelroms.com/emulators-Download">http://www.angelroms.com/emulators-Download</a><!-- m --> .php?system=[system]   *[system] being whatever system you choose of course

then, you can choose a Download , inside that section [system],again from a simple list of normal links, then the URL would become:

<!-- m --><a class="postlink" href="http://www.angelroms.com/emulators-Download">http://www.angelroms.com/emulators-Download</a><!-- m --> .php?system=[system]&Download =[file]  *[file] of course being whatever the user has chosen.


--------

I hope that's better! Just a series of sections leading to 
the [file] in the [system] catagory. I sure hope that clears things up ^_^I actually don't think you need to compound your links in your case. Why not do something like this?<?php
  // this page takes the value stored in $_GET['mix'] and 
  // produces a list of songs for that mix.

  if (!isset($_GET['mix'])) {
      header('Location: <!-- m --><a class="postlink" href="http://www.yoursite.com/'">http://www.yoursite.com/'</a><!-- m -->);
      exit();
  }

  switch ($_GET['mix'))
  {
      case 1: // mix 1
          /* 
            Code which prints a link to all songs for this mix.
            Each song should have a unique ID and this will be 
            used to when generating its chart.
            Example:
            <a href=http://www.htmlforums.com/archive/index.php/"getChart.php?sid=$songID">Song1</a>
          */
          break;
      case 2: // mix 2
          // as above
          break;
      default: // catch all
          // as for mix 1
          break;
  }
?>

<!-- getChart.php file -->
<?php
  if (!isset($_GET['sid'])) {
      header('Location: <!-- m --><a class="postlink" href="http://www.yoursite.com/'">http://www.yoursite.com/'</a><!-- m -->);
      exit();
  }

  // using the value in $_GET['sid'] (the song id) you should have
  // enough information to produce the chart.
?>Well yeah I suppose that would work, but I would like what I stated to begin with so I can learn a more helpful technique that I will use more than just here. I think it would be easier for the user if they can see what is going on, and not have to skip around and have to press the back button to start all over and go to a different section. I would very much like to know how to make just the variables compounding in the URL, and not change what I originally intended on doing..thanks though!There'd be no back button presses with the solution I proposed. If you want to include multiple vars on your url line then separate them with a &

link.php?var=1&var2=2&var3=3

If you really think a visitor gives a monkey about what's in the query part of a URI or that they can, or even want to, work out what's going on from there then you're slightly mad :)

You should always try to code the most efficient way of delivering the content the user wants, as opposed to making it look good in the browser's address bar. If you had a form passing multiple vars via the URI then you would have a string of vars in the address bar. I would never go out of my way to code it that way specifically though.OK, well, uh, I don't understand a single thing in that script above, lol. How the heck do I use it?then I suggest you read some more on PHP and learn how to do what you want. nobody can teach you anything if you don't understand what is going on.I rember doing something similar to this as an experiment,
i used somthing like this.

---main.php---

require('pagedirect.php');
require('header.php');
require('leftcolomn.php');
require($loadpage);
require('footer.php');

---pagedirect.php---
(can't rember exactly i could recall it if required).

it did something like http_get_vars['pageid']; and added .php on to the end then check if it existed, if it did it took it to that page, if not then it went to an error 404 page. overall all it does is look fancy to those who don't understand it, that and help with doing stuff with lots of pages.
-------------

if you want the exact script i could provide it here. (don't have it with me on this computer).
 
Back
Top