Creating Dynamic URLs

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jflash

    Creating Dynamic URLs

    Hello all,

    I feel dumb having to ask this question in the first place, but I just
    can not figure it out. I am wanting to set my site up using dynamic
    urls (I'm assuming that's what they're called, an example of what I
    have in mind is index.php?page=[pagename]). However, I can not figure
    out how to do this. I will eventually want to use SEF urls, but for now
    I'll be content just to have the dynamic urls. If anyone can tell me
    how to do this, I'd really appreciate it. Thanks!

  • Ron Barnett

    #2
    Re: Creating Dynamic URLs

    "jflash" <ki4hrg@gmail.c omwrote in message
    news:1160227193 .004443.197310@ c28g2000cwb.goo glegroups.com.. .
    Hello all,
    >
    I feel dumb having to ask this question in the first place, but I just
    can not figure it out. I am wanting to set my site up using dynamic
    urls (I'm assuming that's what they're called, an example of what I
    have in mind is index.php?page=[pagename]). However, I can not figure
    out how to do this. I will eventually want to use SEF urls, but for now
    I'll be content just to have the dynamic urls. If anyone can tell me
    how to do this, I'd really appreciate it. Thanks!
    $page = $_REQUEST['page'];
    if ($page == 'pageone') include './lib/pageone.php';

    the url ( index.php?page=[pagename] )does not need the square brackets
    note that the parameter names - in this case 'page' is case sensitive


    HTH

    Ron


    Comment

    • usenet+2004@john.dunlop.name

      #3
      Re: Creating Dynamic URLs

      jflash:
      I am wanting to set my site up using dynamic urls
      Why?

      At least you are thinking about URL design before publishing your
      pages: that puts you ahead of the masses. Retrospective URL design
      is, in a word, iffy.
      (I'm assuming that's what they're called, an example of what
      I have in mind is index.php?page=[pagename]).
      'Dynamic URL' is a misleading though common term for URLs with query
      parts. Misleading because there is nothing dynamic about URLs. That
      example, we can say, is a relative reference consisting of a path and a
      query part (square brackets aren't allowed in query parts). Nothing
      more. What the server does with that URL is up to you, but the URL,
      the string of characters, is not dynamic.

      Couple of points on your example:

      1. "Indexes" rarely are indexes. Are you sure there isn't a better
      name? No name, even?

      2. URL suffixes, unless you see the URL as pointing to a particular
      representation of the resource, serve no purpose. It is generally of
      no consequence to users whether you use PHP or some other language to
      create your pages.
      However, I can not figure out how to do this.
      I think another poster has suggested one way.
      I will eventually want to use SEF urls,
      I can guess what you mean by that, but again I think the term is
      misleading.

      --
      Jock

      Comment

      • jflash

        #4
        Re: Creating Dynamic URLs

        Ron: I assume that I simply add that code to my 'initial' page
        (index.php in the example I started with). However, I am curious how I
        define a default page to load (i.e. in my index.php example, how would
        I specify what page to include/what content to display in the event
        that no parameters are entered)? Also, do I have to manually add each
        page for the parameter to include in the file, or is there some way
        that I can use a database for the list of parameters and their
        corresponding pages?

        Jock:

        1. I had originally thought I could use dynamic URLs to pull content
        from a database and display it on a page based on the parameters
        defined in the URL. In any case, I hope that using the dynamic URLs
        will make it easier for my users, particularly once I get search-engine
        friendly URLs set up.

        2. Actually, I already have a version of my site up, I mainly am doing
        this because I am dooing a major overhaul for various other reasons,
        and since I have been wanting to implement this for a while now, it
        seems like a good time to do it.

        3.1. I don't get what you're saying. I wasn't planning on using
        index.php as the base file name, I just used it for an example.
        Actually, now that you say it, I'm thinking I might use the 'index.php'
        part of the URL to serve as a category, then define the specific page
        later. I don't know, I'll decide that later.
        3.2. I'm just using PHP because I know for a fact my server supports
        it, and I see no reason to try anythign else and risk a lack of support
        on the server end of things.

        Thanks for the help!

        On Oct 7, 11:11 am, usenet+2...@joh n.dunlop.name wrote:
        jflash:
        >
        I am wanting to set my site up using dynamic urlsWhy?
        >
        At least you are thinking about URL design before publishing your
        pages: that puts you ahead of the masses. Retrospective URL design
        is, in a word, iffy.
        >
        (I'm assuming that's what they're called, an example of what
        I have in mind is index.php?page=[pagename]).'Dynamic URL' is a misleading though common term for URLs with query
        parts. Misleading because there is nothing dynamic about URLs. That
        example, we can say, is a relative reference consisting of a path and a
        query part (square brackets aren't allowed in query parts). Nothing
        more. What the server does with that URL is up to you, but the URL,
        the string of characters, is not dynamic.
        >
        Couple of points on your example:
        >
        1. "Indexes" rarely are indexes. Are you sure there isn't a better
        name? No name, even?
        >
        2. URL suffixes, unless you see the URL as pointing to a particular
        representation of the resource, serve no purpose. It is generally of
        no consequence to users whether you use PHP or some other language to
        create your pages.
        >
        However, I can not figure out how to do this.I think another poster has suggested one way.
        >
        I will eventually want to use SEF urls,I can guess what you mean by that, but again I think the term is
        misleading.
        >
        --
        Jock

        Comment

        • jflash

          #5
          Re: Creating Dynamic URLs

          I forgot to mention one thing: how can I use this setup to call
          information from a database. For example, I've seen this done where the
          search query from a search on a site is entered into the URL and is
          then searched for in the database. HOw, then, is this done if all of
          the 'redirects' (for lack of a better word) have to be predefined?

          On Oct 7, 5:10 pm, "jflash" <ki4...@gmail.c omwrote:
          Ron: I assume that I simply add that code to my 'initial' page
          (index.php in the example I started with). However, I am curious how I
          define a default page to load (i.e. in my index.php example, how would
          I specify what page to include/what content to display in the event
          that no parameters are entered)? Also, do I have to manually add each
          page for the parameter to include in the file, or is there some way
          that I can use a database for the list of parameters and their
          corresponding pages?
          >
          Jock:
          >
          1. I had originally thought I could use dynamic URLs to pull content
          from a database and display it on a page based on the parameters
          defined in the URL. In any case, I hope that using the dynamic URLs
          will make it easier for my users, particularly once I get search-engine
          friendly URLs set up.
          >
          2. Actually, I already have a version of my site up, I mainly am doing
          this because I am dooing a major overhaul for various other reasons,
          and since I have been wanting to implement this for a while now, it
          seems like a good time to do it.
          >
          3.1. I don't get what you're saying. I wasn't planning on using
          index.php as the base file name, I just used it for an example.
          Actually, now that you say it, I'm thinking I might use the 'index.php'
          part of the URL to serve as a category, then define the specific page
          later. I don't know, I'll decide that later.
          3.2. I'm just using PHP because I know for a fact my server supports
          it, and I see no reason to try anythign else and risk a lack of support
          on the server end of things.
          >
          Thanks for the help!
          >
          On Oct 7, 11:11 am, usenet+2...@joh n.dunlop.name wrote:
          >
          jflash:
          >
          I am wanting to set my site up using dynamic urlsWhy?
          >
          At least you are thinking about URL design before publishing your
          pages: that puts you ahead of the masses. Retrospective URL design
          is, in a word, iffy.
          >
          (I'm assuming that's what they're called, an example of what
          I have in mind is index.php?page=[pagename]).'Dynamic URL' is a misleading though common term for URLs with query
          parts. Misleading because there is nothing dynamic about URLs. That
          example, we can say, is a relative reference consisting of a path and a
          query part (square brackets aren't allowed in query parts). Nothing
          more. What the server does with that URL is up to you, but the URL,
          the string of characters, is not dynamic.
          >
          Couple of points on your example:
          >
          1. "Indexes" rarely are indexes. Are you sure there isn't a better
          name? No name, even?
          >
          2. URL suffixes, unless you see the URL as pointing to a particular
          representation of the resource, serve no purpose. It is generally of
          no consequence to users whether you use PHP or some other language to
          create your pages.
          >
          However, I can not figure out how to do this.I think another poster has suggested one way.
          >
          I will eventually want to use SEF urls,I can guess what you mean by that, but again I think the term is
          misleading.
          >
          --
          Jock

          Comment

          • Colin Fine

            #6
            Re: Creating Dynamic URLs

            jflash wrote:
            >>
            >On Oct 7, 11:11 am, usenet+2...@joh n.dunlop.name wrote:
            >>
            >>jflash:
            >>>I am wanting to set my site up using dynamic urlsWhy?
            >>At least you are thinking about URL design before publishing your
            >>pages: that puts you ahead of the masses. Retrospective URL design
            >>is, in a word, iffy.
            >>>(I'm assuming that's what they're called, an example of what
            >>>I have in mind is index.php?page=[pagename]).'Dynamic URL' is a misleading though common term for URLs with query
            >>parts. Misleading because there is nothing dynamic about URLs. That
            >>example, we can say, is a relative reference consisting of a path and a
            >>query part (square brackets aren't allowed in query parts). Nothing
            >>more. What the server does with that URL is up to you, but the URL,
            >>the string of characters, is not dynamic.
            >>Couple of points on your example:
            >>1. "Indexes" rarely are indexes. Are you sure there isn't a better
            >>name? No name, even?
            >>2. URL suffixes, unless you see the URL as pointing to a particular
            >>representatio n of the resource, serve no purpose. It is generally of
            >>no consequence to users whether you use PHP or some other language to
            >>create your pages.
            >>>However, I can not figure out how to do this.I think another poster has suggested one way.
            >>>I will eventually want to use SEF urls,I can guess what you mean by that, but again I think the term is
            >>misleading.
            >>--
            >>Jock
            >
            I forgot to mention one thing: how can I use this setup to call
            information from a database. For example, I've seen this done where the
            search query from a search on a site is entered into the URL and is
            then searched for in the database. HOw, then, is this done if all of
            the 'redirects' (for lack of a better word) have to be predefined?
            >
            On Oct 7, 5:10 pm, "jflash" <ki4...@gmail.c omwrote:
            >Ron: I assume that I simply add that code to my 'initial' page
            >(index.php in the example I started with). However, I am curious how I
            >define a default page to load (i.e. in my index.php example, how would
            >I specify what page to include/what content to display in the event
            >that no parameters are entered)? Also, do I have to manually add each
            >page for the parameter to include in the file, or is there some way
            >that I can use a database for the list of parameters and their
            >correspondin g pages?
            >>
            >Jock:
            >>
            >1. I had originally thought I could use dynamic URLs to pull content
            >from a database and display it on a page based on the parameters
            >defined in the URL. In any case, I hope that using the dynamic URLs
            >will make it easier for my users, particularly once I get search-engine
            >friendly URLs set up.
            >>
            >2. Actually, I already have a version of my site up, I mainly am doing
            >this because I am dooing a major overhaul for various other reasons,
            >and since I have been wanting to implement this for a while now, it
            >seems like a good time to do it.
            >>
            >3.1. I don't get what you're saying. I wasn't planning on using
            >index.php as the base file name, I just used it for an example.
            >Actually, now that you say it, I'm thinking I might use the 'index.php'
            >part of the URL to serve as a category, then define the specific page
            >later. I don't know, I'll decide that later.
            >3.2. I'm just using PHP because I know for a fact my server supports
            >it, and I see no reason to try anythign else and risk a lack of support
            >on the server end of things.
            >>
            >Thanks for the help!
            [Top posting fixed]

            I don't fully understand what you are asking, but it seems to me that
            you have an imperfect understanding of how CGI works.

            A CGI script (such as a PHP program on a website) is a program that
            generates as output the HTML that the web server will send to the browser.

            Usually, the script takes arguments from the URL (usually the part after
            the '?') to decide what to display, and very often it will obtain some
            of the data on the page from a database.

            Often, the script is capable of producing utterly different pages
            depending on the input: for example, many CGI scripts display
            information relating to a particular key in the database (a particular
            site, person, company, date or whatever) and if called without the key
            will display a different page that asks the user to specify the key.
            Then the 'Submit' from that will go to the *same* script, but this time
            with the data it needs.

            If the URL has no CGI arguments, the program must cope with that case
            and do something appropriate, for example request the information
            intneeds as in the previous paragraph.

            If you want not just to generate distinct pages, but to go to different
            existing pages, you can do it by generating a HTTP header that redirects
            to the appropriate page.

            Does this help, or have I misunderstood your issue?

            Colin

            Comment

            • Ron Barnett

              #7
              Re: Creating Dynamic URLs

              "Colin Fine" <news@kindness. demon.co.ukwrot e in message
              news:egalj3$lfp $1$8302bc10@new s.demon.co.uk.. .
              jflash wrote:
              >>>
              >>On Oct 7, 11:11 am, usenet+2...@joh n.dunlop.name wrote:
              >>>
              >>>jflash:
              >>>>I am wanting to set my site up using dynamic urlsWhy?
              >>>At least you are thinking about URL design before publishing your
              >>>pages: that puts you ahead of the masses. Retrospective URL design
              >>>is, in a word, iffy.
              >>>>(I'm assuming that's what they're called, an example of what
              >>>>I have in mind is index.php?page=[pagename]).'Dynamic URL' is a
              >>>>misleadin g though common term for URLs with query
              >>>parts. Misleading because there is nothing dynamic about URLs. That
              >>>example, we can say, is a relative reference consisting of a path and a
              >>>query part (square brackets aren't allowed in query parts). Nothing
              >>>more. What the server does with that URL is up to you, but the URL,
              >>>the string of characters, is not dynamic.
              >>>Couple of points on your example:
              >>>1. "Indexes" rarely are indexes. Are you sure there isn't a better
              >>>name? No name, even?
              >>>2. URL suffixes, unless you see the URL as pointing to a particular
              >>>representati on of the resource, serve no purpose. It is generally of
              >>>no consequence to users whether you use PHP or some other language to
              >>>create your pages.
              >>>>However, I can not figure out how to do this.I think another poster
              >>>>has suggested one way.
              >>>>I will eventually want to use SEF urls,I can guess what you mean by
              >>>>that, but again I think the term is
              >>>misleading .
              >>>--
              >>>Jock
              >>
              >
              I forgot to mention one thing: how can I use this setup to call
              information from a database. For example, I've seen this done where the
              search query from a search on a site is entered into the URL and is
              then searched for in the database. HOw, then, is this done if all of
              the 'redirects' (for lack of a better word) have to be predefined?

              On Oct 7, 5:10 pm, "jflash" <ki4...@gmail.c omwrote:
              Ron: I assume that I simply add that code to my 'initial' page
              (index.php in the example I started with). However, I am curious how I
              define a default page to load (i.e. in my index.php example, how would
              I specify what page to include/what content to display in the event
              that no parameters are entered)? Also, do I have to manually add each
              page for the parameter to include in the file, or is there some way
              that I can use a database for the list of parameters and their
              corresponding pages?
              >
              Jock:
              >
              1. I had originally thought I could use dynamic URLs to pull content
              from a database and display it on a page based on the parameters
              defined in the URL. In any case, I hope that using the dynamic URLs
              will make it easier for my users, particularly once I get search-engine
              friendly URLs set up.
              >
              2. Actually, I already have a version of my site up, I mainly am doing
              this because I am dooing a major overhaul for various other reasons,
              and since I have been wanting to implement this for a while now, it
              seems like a good time to do it.
              >
              3.1. I don't get what you're saying. I wasn't planning on using
              index.php as the base file name, I just used it for an example.
              Actually, now that you say it, I'm thinking I might use the 'index.php'
              part of the URL to serve as a category, then define the specific page
              later. I don't know, I'll decide that later.
              3.2. I'm just using PHP because I know for a fact my server supports
              it, and I see no reason to try anythign else and risk a lack of support
              on the server end of things.
              >
              Thanks for the help!
              >
              [Top posting fixed]
              >
              I don't fully understand what you are asking, but it seems to me that you
              have an imperfect understanding of how CGI works.
              >
              A CGI script (such as a PHP program on a website) is a program that
              generates as output the HTML that the web server will send to the browser.
              >
              Usually, the script takes arguments from the URL (usually the part after
              the '?') to decide what to display, and very often it will obtain some of
              the data on the page from a database.
              >
              Often, the script is capable of producing utterly different pages
              depending on the input: for example, many CGI scripts display information
              relating to a particular key in the database (a particular site, person,
              company, date or whatever) and if called without the key will display a
              different page that asks the user to specify the key. Then the 'Submit'
              from that will go to the *same* script, but this time with the data it
              needs.
              >
              If the URL has no CGI arguments, the program must cope with that case and
              do something appropriate, for example request the information intneeds as
              in the previous paragraph.
              >
              If you want not just to generate distinct pages, but to go to different
              existing pages, you can do it by generating a HTTP header that redirects
              to the appropriate page.
              >
              Does this help, or have I misunderstood your issue?
              >
              Colin
              Hi Jock,

              The explanation Colin has given is absolutely correct but I suspect you are
              still floundering ?

              referring back the code example I gave

              $page = $_REQUEST['page'];
              if ($page == 'pageone') include './lib/pageone.php';

              This needs to be inserted as you guessed in index.php
              calling index.php with a parameter 'page' i.e. //index.php?page= something
              will cause the $_REQUEST array to contain an element 'page' with a value
              'something'
              having extracted the key / value pair from the array it as in the example
              you can do whatever you like with the 'something' - you can simply haul in
              another static page, or call a routine that uses 'something' as the key to
              extract data from a database.
              the absence of a parameter is simply the default call for the page
              index.php, so I would assume that it was a screen with some data entry that
              would then be used in a subsequent call. - All this is simple HTML / HTTP
              and not really PHP at all.

              Cheers

              Ron


              Comment

              • jflash

                #8
                Re: Creating Dynamic URLs

                OK, I am now fairly thoroughly confused. What I am asking is for a way
                to have a page which can display information from a database filtered
                and/or sorted based on arguments supplied by the user in the URL. I
                wish I could explain it better, but that's the best way I know how.
                Anything else that I need to know, I suppose I can figure out later.
                Right now, I'm just trying to get the sorting/filtering down.

                On Oct 8, 11:19 am, "Ron Barnett" <ron.REM...@RJB arnett.co.uk.RE MOVE>
                wrote:
                "Colin Fine" <n...@kindness. demon.co.ukwrot e in messagenews:ega lj3$lfp$1$8302b c10@news.demon. co.uk...
                >
                jflash wrote:
                >
                >On Oct 7, 11:11 am, usenet+2...@joh n.dunlop.name wrote:
                >
                >>jflash:
                >>>I am wanting to set my site up using dynamic urlsWhy?
                >>At least you are thinking about URL design before publishing your
                >>pages: that puts you ahead of the masses. Retrospective URL design
                >>is, in a word, iffy.
                >>>(I'm assuming that's what they're called, an example of what
                >>>I have in mind is index.php?page=[pagename]).'Dynamic URL' is a
                >>>misleading though common term for URLs with query
                >>parts. Misleading because there is nothing dynamic about URLs. That
                >>example, we can say, is a relative reference consisting of a path and a
                >>query part (square brackets aren't allowed in query parts). Nothing
                >>more. What the server does with that URL is up to you, but the URL,
                >>the string of characters, is not dynamic.
                >>Couple of points on your example:
                >>1. "Indexes" rarely are indexes. Are you sure there isn't a better
                >>name? No name, even?
                >>2. URL suffixes, unless you see the URL as pointing to a particular
                >>representatio n of the resource, serve no purpose. It is generally of
                >>no consequence to users whether you use PHP or some other language to
                >>create your pages.
                >>>However, I can not figure out how to do this.I think another poster
                >>>has suggested one way.
                >>>I will eventually want to use SEF urls,I can guess what you mean by
                >>>that, but again I think the term is
                >>misleading.
                >>--
                >>Jock
                >
                I forgot to mention one thing: how can I use this setup to call
                information from a database. For example, I've seen this done where the
                search query from a search on a site is entered into the URL and is
                then searched for in the database. HOw, then, is this done if all of
                the 'redirects' (for lack of a better word) have to be predefined?
                >
                On Oct 7, 5:10 pm, "jflash" <ki4...@gmail.c omwrote:
                >Ron: I assume that I simply add that code to my 'initial' page
                >(index.php in the example I started with). However, I am curious how I
                >define a default page to load (i.e. in my index.php example, how would
                >I specify what page to include/what content to display in the event
                >that no parameters are entered)? Also, do I have to manually add each
                >page for the parameter to include in the file, or is there some way
                >that I can use a database for the list of parameters and their
                >correspondin g pages?
                >
                >Jock:
                >
                >1. I had originally thought I could use dynamic URLs to pull content
                >from a database and display it on a page based on the parameters
                >defined in the URL. In any case, I hope that using the dynamic URLs
                >will make it easier for my users, particularly once I get search-engine
                >friendly URLs set up.
                >
                >2. Actually, I already have a version of my site up, I mainly am doing
                >this because I am dooing a major overhaul for various other reasons,
                >and since I have been wanting to implement this for a while now, it
                >seems like a good time to do it.
                >
                >3.1. I don't get what you're saying. I wasn't planning on using
                >index.php as the base file name, I just used it for an example.
                >Actually, now that you say it, I'm thinking I might use the 'index.php'
                >part of the URL to serve as a category, then define the specific page
                >later. I don't know, I'll decide that later.
                >3.2. I'm just using PHP because I know for a fact my server supports
                >it, and I see no reason to try anythign else and risk a lack of support
                >on the server end of things.
                >
                >Thanks for the help!
                >
                [Top posting fixed]
                >
                I don't fully understand what you are asking, but it seems to me that you
                have an imperfect understanding of how CGI works.
                >
                A CGI script (such as a PHP program on a website) is a program that
                generates as output the HTML that the web server will send to the browser.
                >
                Usually, the script takes arguments from the URL (usually the part after
                the '?') to decide what to display, and very often it will obtain some of
                the data on the page from a database.
                >
                Often, the script is capable of producing utterly different pages
                depending on the input: for example, many CGI scripts display information
                relating to a particular key in the database (a particular site, person,
                company, date or whatever) and if called without the key will display a
                different page that asks the user to specify the key. Then the 'Submit'
                from that will go to the *same* script, but this time with the data it
                needs.
                >
                If the URL has no CGI arguments, the program must cope with that case and
                do something appropriate, for example request the information intneeds as
                in the previous paragraph.
                >
                If you want not just to generate distinct pages, but to go to different
                existing pages, you can do it by generating a HTTP header that redirects
                to the appropriate page.
                >
                Does this help, or have I misunderstood your issue?
                >
                ColinHi Jock,
                >
                The explanation Colin has given is absolutely correct but I suspect you are
                still floundering ?
                >
                referring back the code example I gave
                >
                $page = $_REQUEST['page'];
                if ($page == 'pageone') include './lib/pageone.php';
                >
                This needs to be inserted as you guessed in index.php
                calling index.php with a parameter 'page' i.e. //index.php?page= something
                will cause the $_REQUEST array to contain an element 'page' with a value
                'something'
                having extracted the key / value pair from the array it as in the example
                you can do whatever you like with the 'something' - you can simply haul in
                another static page, or call a routine that uses 'something' as the key to
                extract data from a database.
                the absence of a parameter is simply the default call for the page
                index.php, so I would assume that it was a screen with some data entry that
                would then be used in a subsequent call. - All this is simple HTML / HTTP
                and not really PHP at all.
                >
                Cheers
                >
                Ron

                Comment

                • Pedro Graca

                  #9
                  Re: Creating Dynamic URLs

                  jflash top-posted:
                  OK, I am now fairly thoroughly confused. What I am asking is for a way
                  to have a page which can display information from a database filtered
                  and/or sorted based on arguments supplied by the user in the URL. I
                  wish I could explain it better, but that's the best way I know how.
                  Anything else that I need to know, I suppose I can figure out later.
                  Right now, I'm just trying to get the sorting/filtering down.
                  Can you make a page that displays "Hello, <USER>!" when <USERcomes
                  from the query string?

                  Suppose I go to http://www.yourserver.com/hello.php?user=Pedro
                  The "hello.php" script would be something like

                  <?php
                  if ((isset($_GET['user'])) && ($_GET['user'] != '')) {
                  echo "Hello, {$_GET['user']}!";
                  } else {
                  echo "Hello, anonymous!";
                  }
                  ?>

                  It's just about the same thing when you want to use data from the query
                  string for database selection/sort. You just need to get the data and
                  incorporate it in the SQL commands (*after validating the data*).

                  --
                  File not found: (R)esume, (R)etry, (R)erun, (R)eturn, (R)eboot

                  Comment

                  • Colin Fine

                    #10
                    Re: Creating Dynamic URLs

                    jflash wrote:
                    OK, I am now fairly thoroughly confused. What I am asking is for a way
                    to have a page which can display information from a database filtered
                    and/or sorted based on arguments supplied by the user in the URL. I
                    wish I could explain it better, but that's the best way I know how.
                    Anything else that I need to know, I suppose I can figure out later.
                    Right now, I'm just trying to get the sorting/filtering down.
                    >
                    On Oct 8, 11:19 am, "Ron Barnett" <ron.REM...@RJB arnett.co.uk.RE MOVE>
                    wrote:
                    >"Colin Fine" <n...@kindness. demon.co.ukwrot e in messagenews:ega lj3$lfp$1$8302b c10@news.demon. co.uk...
                    >>
                    >>jflash wrote:
                    >>>>On Oct 7, 11:11 am, usenet+2...@joh n.dunlop.name wrote:
                    >>>>>jflash:
                    >>>>>>I am wanting to set my site up using dynamic urlsWhy?
                    >>>>>At least you are thinking about URL design before publishing your
                    >>>>>pages: that puts you ahead of the masses. Retrospective URL design
                    >>>>>is, in a word, iffy.
                    >>>>>>(I'm assuming that's what they're called, an example of what
                    >>>>>>I have in mind is index.php?page=[pagename]).'Dynamic URL' is a
                    >>>>>>misleadin g though common term for URLs with query
                    >>>>>parts. Misleading because there is nothing dynamic about URLs. That
                    >>>>>example, we can say, is a relative reference consisting of a path and a
                    >>>>>query part (square brackets aren't allowed in query parts). Nothing
                    >>>>>more. What the server does with that URL is up to you, but the URL,
                    >>>>>the string of characters, is not dynamic.
                    >>>>>Couple of points on your example:
                    >>>>>1. "Indexes" rarely are indexes. Are you sure there isn't a better
                    >>>>>name? No name, even?
                    >>>>>2. URL suffixes, unless you see the URL as pointing to a particular
                    >>>>>representa tion of the resource, serve no purpose. It is generally of
                    >>>>>no consequence to users whether you use PHP or some other language to
                    >>>>>create your pages.
                    >>>>>>However , I can not figure out how to do this.I think another poster
                    >>>>>>has suggested one way.
                    >>>>>>I will eventually want to use SEF urls,I can guess what you mean by
                    >>>>>>that, but again I think the term is
                    >>>>>misleading .
                    >>>>>--
                    >>>>>Jock
                    >>>I forgot to mention one thing: how can I use this setup to call
                    >>>informatio n from a database. For example, I've seen this done where the
                    >>>search query from a search on a site is entered into the URL and is
                    >>>then searched for in the database. HOw, then, is this done if all of
                    >>>the 'redirects' (for lack of a better word) have to be predefined?
                    >>>On Oct 7, 5:10 pm, "jflash" <ki4...@gmail.c omwrote:
                    >>>>Ron: I assume that I simply add that code to my 'initial' page
                    >>>>(index.ph p in the example I started with). However, I am curious how I
                    >>>>define a default page to load (i.e. in my index.php example, how would
                    >>>>I specify what page to include/what content to display in the event
                    >>>>that no parameters are entered)? Also, do I have to manually add each
                    >>>>page for the parameter to include in the file, or is there some way
                    >>>>that I can use a database for the list of parameters and their
                    >>>>correspondi ng pages?
                    >>>>Jock:
                    >>>>1. I had originally thought I could use dynamic URLs to pull content
                    >>>>from a database and display it on a page based on the parameters
                    >>>>defined in the URL. In any case, I hope that using the dynamic URLs
                    >>>>will make it easier for my users, particularly once I get search-engine
                    >>>>friendly URLs set up.
                    >>>>2. Actually, I already have a version of my site up, I mainly am doing
                    >>>>this because I am dooing a major overhaul for various other reasons,
                    >>>>and since I have been wanting to implement this for a while now, it
                    >>>>seems like a good time to do it.
                    >>>>3.1. I don't get what you're saying. I wasn't planning on using
                    >>>>index.php as the base file name, I just used it for an example.
                    >>>>Actually, now that you say it, I'm thinking I might use the 'index.php'
                    >>>>part of the URL to serve as a category, then define the specific page
                    >>>>later. I don't know, I'll decide that later.
                    >>>>3.2. I'm just using PHP because I know for a fact my server supports
                    >>>>it, and I see no reason to try anythign else and risk a lack of support
                    >>>>on the server end of things.
                    >>>>Thanks for the help!
                    >>[Top posting fixed]
                    >>I don't fully understand what you are asking, but it seems to me that you
                    >>have an imperfect understanding of how CGI works.
                    >>A CGI script (such as a PHP program on a website) is a program that
                    >>generates as output the HTML that the web server will send to the browser.
                    >>Usually, the script takes arguments from the URL (usually the part after
                    >>the '?') to decide what to display, and very often it will obtain some of
                    >>the data on the page from a database.
                    >>Often, the script is capable of producing utterly different pages
                    >>depending on the input: for example, many CGI scripts display information
                    >>relating to a particular key in the database (a particular site, person,
                    >>company, date or whatever) and if called without the key will display a
                    >>different page that asks the user to specify the key. Then the 'Submit'
                    >>from that will go to the *same* script, but this time with the data it
                    >>needs.
                    >>If the URL has no CGI arguments, the program must cope with that case and
                    >>do something appropriate, for example request the information intneeds as
                    >>in the previous paragraph.
                    >>If you want not just to generate distinct pages, but to go to different
                    >>existing pages, you can do it by generating a HTTP header that redirects
                    >>to the appropriate page.
                    >>Does this help, or have I misunderstood your issue?
                    >>ColinHi Jock,
                    >The explanation Colin has given is absolutely correct but I suspect you are
                    >still floundering ?
                    >>
                    >referring back the code example I gave
                    >>
                    >$page = $_REQUEST['page'];
                    >if ($page == 'pageone') include './lib/pageone.php';
                    >>
                    >This needs to be inserted as you guessed in index.php
                    >calling index.php with a parameter 'page' i.e. //index.php?page= something
                    >will cause the $_REQUEST array to contain an element 'page' with a value
                    >'something'
                    >having extracted the key / value pair from the array it as in the example
                    >you can do whatever you like with the 'something' - you can simply haul in
                    >another static page, or call a routine that uses 'something' as the key to
                    >extract data from a database.
                    >the absence of a parameter is simply the default call for the page
                    >index.php, so I would assume that it was a screen with some data entry that
                    >would then be used in a subsequent call. - All this is simple HTML / HTTP
                    >and not really PHP at all.
                    >>
                    >Cheers
                    >>
                    >Ron
                    >
                    To do the sorting and filtering, you need to generate SQL queries based
                    on the arguments, and pass them to your database system.

                    Look at the examples in http://www.php.net/manual/en/ref.mysql.php.

                    Your query will be this sort of thing:

                    $query = "SELECT field1, field2, field3 FROM table WHERE ".
                    "match1 = '{$_GET['data1']}' AND ".
                    "match2 = '{$_GET['data2']}'";

                    from
                    index.php?data1 =xxx&data2=yyy

                    Colin

                    Comment

                    • Todd

                      #11
                      Re: Creating Dynamic URLs

                      In your example you could set up the index.php file as below:

                      <?php
                      //index php
                      //this is the shell for your page.
                      echo "<!DOCTYPE html";
                      echo "PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"";
                      echo "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">";
                      echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\"
                      lang=\"en\">";
                      echo "<head>";
                      echo " <meta http-equiv=\"Content-Type\" content=\"text/html;
                      charset=utf-8\" />";
                      echo " <title>Dummy Title</title>";
                      echo "</head>";
                      echo "<body>";

                      if (isset($_GET['con'])) {
                      $con = $_GET['con'] . ".inc";
                      } else {
                      $con = "nocontent.inc" ;
                      }
                      require $con;

                      echo "</body>";
                      echo "</html>";
                      ?>

                      Then another file named hello.inc.
                      <?php
                      //hello.inc
                      if (isset($_GET['user'])) {
                      $user = $_GET['user'];
                      echo "<p>Hello there $user</p>";
                      } else {
                      echo "<p>Hello there mysterious stranger</p>";
                      }
                      ?>

                      You would then call this page:



                      Of course you would have to have a file nocontent.inc that would handle
                      requests that do not have the cont set.

                      You could then do things like create a form page ... say getuserqry called
                      by: http://yourserver.yourdomain/index.php?cont=getuserqry
                      then when this form posts the action is:



                      showuser.inc would use the post variables and perform some action (say query
                      a database) and present the data to the user.

                      I hope this all makes sense to you and is in line with what you are asking.

                      "Pedro Graca" <hexkid@dodgeit .comwrote in message
                      news:slrneiimni .dls.hexkid@ID-203069.user.ind ividual.net...
                      jflash top-posted:
                      >OK, I am now fairly thoroughly confused. What I am asking is for a way
                      >to have a page which can display information from a database filtered
                      >and/or sorted based on arguments supplied by the user in the URL. I
                      >wish I could explain it better, but that's the best way I know how.
                      >Anything else that I need to know, I suppose I can figure out later.
                      >Right now, I'm just trying to get the sorting/filtering down.
                      >
                      Can you make a page that displays "Hello, <USER>!" when <USERcomes
                      from the query string?
                      >
                      Suppose I go to http://www.yourserver.com/hello.php?user=Pedro
                      The "hello.php" script would be something like
                      >
                      <?php
                      if ((isset($_GET['user'])) && ($_GET['user'] != '')) {
                      echo "Hello, {$_GET['user']}!";
                      } else {
                      echo "Hello, anonymous!";
                      }
                      ?>
                      >
                      It's just about the same thing when you want to use data from the query
                      string for database selection/sort. You just need to get the data and
                      incorporate it in the SQL commands (*after validating the data*).
                      >
                      --
                      File not found: (R)esume, (R)etry, (R)erun, (R)eturn, (R)eboot

                      Comment

                      Working...