So if you are using Apache as your webserver you can use mod_rewrite to
rewrite the URL to something else.

So for example, create a rewrite rule to rewrite firstname_lastname to
people.php?fn=firstname&ln=lastname

RewriteRule ^([^-]+)\-([^-]+)\.html$ people.php?fn=$1&ln=$2 [L,NC,NS]

Next, the PHP page will have to do something to make it friendlier and
expect the person's name and not a number, then lookup the number so it
can be used in a query etc.

So for a URL like this:  http://www.tokyocomedy.com/firstname-lastname.html

It will appear to your page as this:  people.php?fn=firstname&ln=lastname

So, at the top of your page or wherever you would normally look up the
record for person=6:

$result = yoursqlfunc("SELECT person FROM sometable WHERE
firstname='$_GET[fn]' AND lastname='$_GET[ln]'");

Then use your SQL function to get person from $result.

Then you should have person=6 and continue as normal.

-Shawn



Dave M G wrote:
> PHP General,
> 
>       I have a PHP/MySQL web site where there are profiles for performers at
> a comedy show. The profiles are accessed by passing a variable to the
> PHP script via URL, which can then look up the right performer data in
> the database.
>       The resulting URL looks like this:
>       http://www.tokyocomedy.com/people.php?person=6
>       However, having "?person=6" in the URL is not only ugly, but it makes
> it hard for people to remember URLs and for the performers to use them
> when sending out information about themselves.
>       It would be much nicer to have the url look more like this:
>       http://www.tokyocomedy.com/firstname-lastname
>       Or something like that.
> 
>       But I can't figure out if there is a way to control the way the URL
> reads after the performer has been looked up. And, even if I could,
> would the system be able to retrieve performer data if someone typed the
> name directly into the URL.
> 
>       Obviously, I'm still a bit of a beginner with PHP. I may have
> approached this issue from the wrong starting point, so please let me
> know if I'm missing something fundamental.
> 
>       Thank you for any advice you may have.
> 
> --
> Dave M G

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to