473,382 Members | 1,749 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

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!

Oct 7 '06 #1
10 4857
"jflash" <ki****@gmail.comwrote in message
news:11**********************@c28g2000cwb.googlegr oups.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
Oct 7 '06 #2
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

Oct 7 '06 #3
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...@john.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
Oct 7 '06 #4
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.comwrote:
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...@john.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
Oct 7 '06 #5
jflash wrote:
>>
On Oct 7, 11:11 am, usenet+2...@john.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
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.comwrote:
>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
Oct 8 '06 #6
"Colin Fine" <ne**@kindness.demon.co.ukwrote in message
news:eg*******************@news.demon.co.uk...
jflash wrote:
>>>
On Oct 7, 11:11 am, usenet+2...@john.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
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.comwrote:
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
Oct 8 '06 #7
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...@RJBarnett.co.uk.REMOVE>
wrote:
"Colin Fine" <n...@kindness.demon.co.ukwrote in messagenews:eg*******************@news.demon.co.uk ...
jflash wrote:
>On Oct 7, 11:11 am, usenet+2...@john.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
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.comwrote:
>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?
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
Oct 8 '06 #8
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
Oct 8 '06 #9
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...@RJBarnett.co.uk.REMOVE>
wrote:
>"Colin Fine" <n...@kindness.demon.co.ukwrote in messagenews:eg*******************@news.demon.co.uk ...
>>jflash wrote:
On Oct 7, 11:11 am, usenet+2...@john.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
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.comwrote:
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?
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
Oct 8 '06 #10
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:

http://yourserver.yourdomain/index.p...ello&user=Phil

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:

http://yourserver.yourdomain/index.php?cont=showuser

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" <he****@dodgeit.comwrote in message
news:sl*******************@ID-203069.user.individual.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

Oct 8 '06 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Seun Osewa | last post by:
Hi, I'm thinking of an architecture for a medium-complexity dynamic site as follows: - I use one php file, say a.php as the entry point for the entire site. PATH_INFO allows me to pass...
2
by: PK | last post by:
Hello, I am looking for help on the following. I'm trying to create a custom browser toolbar button that will do a few things. One that I'm trying to do at the moment is just simply return the...
0
by: only_me | last post by:
Not a coding question as such but highly related to asp/dynamic pages issues : has anyone any suggestions on the following ASP sites are generally (always) of a dynamic nature, pages can be...
1
by: Benny | last post by:
Hi All, Good Morning! I just need to create 36 pages dynamically, each us a webpage for each person. Its dynamic from the Db, and the no seems to be growing. I am hoping to have short URLs...
2
by: Patrick | last post by:
I want to define a set of web-form templates in XML and render the equivalent web-form with ASP.NET, then process any input server controls on the form. Reading the XML file from Page_load is...
3
by: JL | last post by:
I have a VB.NET desktop program that reads/writes data to a server using a Java-based Web Service. This web service, in identical formats, is located on several servers with each server being a...
0
by: eric.olstad | last post by:
I want to create a web site that can dynamically creates tabs -- like firefox functionality built into a web site. Take a look at this site to get an idea of what I'm looking to do:...
4
by: Nicole | last post by:
Hello, Can anyone tell me or give me an online tool which can help me to convert php dynamic urls to html urls to make a google friendly site.I dont have apache server on my computer and I dont...
9
by: Tarscher | last post by:
hi all, I have this seemingly simple problem. I have lost a lot of time on it though. When a user selects a value from a dropdownlist (static control) a dynamic control is generated. I have...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.