|
Posted by Todd on 10/08/06 22:25
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.php?cont=hello&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" <hexkid@dodgeit.com> wrote in message
news:slrneiimni.dls.hexkid@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 <USER> comes
> 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
Navigation:
[Reply to this message]
|