Re: Can the URL be controlled for more user-friendly readability?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, December 23, 2005 10:43 pm, Dave M G wrote:
> 	I have a PHP/MySQL web site where there are profiles for performers
> at
> a comedy show.

Cool!

Every entertainment venue should do this.

> 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.

You mean like this?
http://uncommonground.com/artist_profile/Ellen+Rosner
:-)

#1:
Re-name your script from "people.php" to just "people"

In your example, if you actually want the HOMEPAGE to be the
"people.php" script, you can skip this step, so long as your homepage
is a PHP script.
(IE, it's index.php not index.htm, or your server is configured to
pass .htm files through PHP)

#2:
Force the web server to treat "people" as a PHP script even though it
doesn't end in .php
Open up .htaccess on the server (or create one) and add this:
<Files people>
  ForceType application/x-httpd-php
<Files>

Also skip this step if you want your HOMEPAGE to be your "people" page
-- or use it to force "index.htm" to be PHP script if it's not
already:
<Files index.htm>
  ForceType application/x-httpd-php
</Files>

#3:
I was going to type a lot of PHP stuff here...
I'll just show my source code and comment on it:
http://uncommonground.com/artist_profile.phps

The 'require' lines connect to the database and define some functions
you can ignore, so forget those.

$search_key = $_SERVER['PATH_INFO'];

This is the crucial "Magic Line" that gives you the data:
"/Dave+Martin"

Only sometimes it's:
"/artist_id/42"
as you'll see if you click through some of the links to other artists
on the site.
See the list of performance dates at the bottom of the page here:
http://uncommonground.com/artist_profile/Ellen+Rosner
[More on this "artist_id/42" later.]

I first strip off the "/" in front to get:
"Dave+Martin"

Or maybe it's:
"artist_id/42"

Use urldecode() to change "Dave+Martin" into "Dave Martin"

Next, I check to see if I have an artist_id or if I want to look up
the name:
    if (stristr($search_key, 'artist_id')){

Then I either use the artist_id I was handed (as your script does
right now) or I look up the name.

If you do this on your HOMEPAGE, you'd want something like:

if (stristr($search_key, 'artist_id')){
  //We KNOW who the artist is, look them up by ID
}
elseif (strlen($search_key)){
  //There was an artist name in PATH_INFO
  //Search the database for that name
}
else{
  //There was NOTHING in PATH_INFO, so dump out the actual HOMEPAGE
  ?>
  <html><head>Tokyo Comedy</head><body>Welcome to Tokyo
Comedy!</body></html>
  <?php
}
only a lot more code in there :-)

Inside the strlen($search_key) branch...
If more than one name matches, dump out all the names for the user to
pick one.  Example:
http://uncommonground.com/artist_profile/Ellen

Then they'll click on the link, and you'll have the exact artist_id
you want.

After that, it's all just a bunch of SQL and PHP to dump out what I
want about the artist.

Which in my case has gotten pretty extensive and built-up over the
past several years, so it's a BUNCH of SQL and PHP, but there it is.

Here are the table names and what they are to help explain what the
queries are doing:

entities: core artist info: name, url, email, bio, etc
samples: headshots and thumbnails
cache_list: MP3s of previous performances here at our venue
cdbaby: CDBaby albumcode for CDs of this artist at http://cdbaby.com
events: performance date calendar

If anything is at all unclear, feel free to ask!

The rest of this post is just wacky ideas of things I do, that you
might want to consider doing, with your system after you get it
working.

Or maybe they'll inspire you to other better ideas -- Or at least more
appropriate for a Comedy Club.  (We're acoustic music with very very
very rare comedy acts.)

You should probably stop reading and start coding the basic simplest
page you can now, and then stop and re-read from here forward to start
dreaming up your own stuff to do...

We allow artists to log in and input their own Bios and upload Photos
(as many as they want) and Thumbnails and...

So I don't put in any of this stuff for the Artist Profile.  With
2000+ artists, and an average of 3 acts per night, every night,
there's NO WAY I'd have time to maintain all this data.

Total self-service on these pages.

If you need to see the artist login/backend in action, I can hook you
up with an artist account and a gig in, oh, 2038 so you'll see it in
action.

Artists also put in their zipcode which gives me the GPS data to list
artists from regions to cross-promote artists with each other based on
their home-town (or current base of operations at least).  Some
artists have only provided city/state or have given me nothing at all,
and sometimes we only have one artist from a certain country (Norway,
for example) and so the "Relativistic Proximity" calculation got a bit
hairy for that... :-)  It's giving each artist a "score" relative to
the artist I'm displaying, and picking the 3 "nearest"

I also link to their CDBaby pages (with a referral $$$ code) to help
them sell more CDs.  I auto-search through CDBaby in a cron job rather
than relying on artists to input that, cuz CDBaby is so clean and
simple.

Artists also put in "internal" data like a stage plot, which our sound
engineers see an Intranet page -- And the sound engineer records
free-form notes like "Use an SM58 ; He bops his head too much for the
87A" or "This guy sucks!!! Never book him again"

The engineer also records two crucial (for us) numbers:
Draw: (how many warm bodies this artist delivered)
Rating: (1 sucks ; 10 rocks)

The Talent Buyer (that's me) can then review the artist's history
EASILY (and somewhat objectively) when making booking decisions,
rather than relying on faulty (perhaps drunken) memories of who was
who and what they were like.

I'm also going to add a number for their Tip Jar $$$ (we are
prohibited by City Ordinance from charging a Cover) so we can report
to Box Office Network automatically.

This is also all tied into our web-calendar, which DRIVES our booking
process.  No more do I take endless phone calls about "What's
available?" -- Artists know they can check the web-site and see for
themselves.

The site also sends automated email confirmations for every gig
booked, listing each artists' time slot and Cc:-ing each artist on the
night of the added booking.  We have not had a single double-booking
(that actually went to the night of the event) since this system went
into place.  Artists notice right away when somebody else is in their
slot in the email, and we can FIX the problem months in advance.  I
cannot stress how much this has improved quality of life by reducing
stress.

Not to mention cutting my phone calls and emails by one-third, which
is a huge savings.

Oh, and the confirmation email gives all the artitsts the other
artists' emails and websites, so they don't come bugging me for it --
They often want to listen to the other act to see what they're getting
into, and to explore cross-promotion possibilities, or just to make
sure the night won't suck because of the other act. :-)

I'm using PostgreSQL, not MySQL for historical reasons
(my first webhost couldn't get MySQL to install, but had PostgreSQL
running)
You'll have gloss over the pg_exec and SQL nitpiking.
~* is a REGEX, but you could use LIKE in MySQL too.

> 	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.

Hope this isn't all too overwhelming...

The CORE of the technology is just $_SERVER['PATH_INFO'] but I figured
I might as well give you the whole ball of wax, eh?

-- 
Like Music?
http://l-i-e.com/artists.htm

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux