Jump to content
MsKazza

Name a php page after a field in mysql? possible?

Recommended Posts

Hi :)

Not even sure if this is possible, but well here goes:

We have a wholesale site where companies, organisations, clubs etc can buy products.  We are setting it up so that these organisations can pick their items then our system will set up a webshop for them, they can then send the link to their employees, members to order the items that the company has chosen ahead of time.

our site would be http://www.ourcompanyname.com/productpage.php?companyName=ourClient

we would like if poss : http://www.ourcompanyname.com/ClientOrganisationName(either with or without the PHP extension).

ClientOrganisationName would be taken from their record in mysql.

If this is possible could someone please just tell me what i need to look up. I think wordpress has something similar which is prob where i thought about using on our site.

thanks very much,

MsKazza.

Share this post


Link to post
Share on other sites

You can definitely do /ClientOrganizationName being treated as /productpage.php?companyName=ClientOrganizationName. Note the two names are the same.

The concept is called URL rewriting and there's a lot of information on the internet about it. What you do is tell your web server that requests for a URL in a certain pattern should be "rewritten" to another URL. In your case, you would tell it that a URL that is a name without any "directory" (so /Client matches but not /foo/Client  or /Client/foo) takes that name and gives it to productpage.php.

If you're using WordPress, IIRC it has a URL rewriting feature by itself (the web server was told that everything should go through WP, and then WP itself decides what to do) so you would tell WP that pages in that pattern should be treated a certain way.

There is one restriction, though: this URL pattern needs to be dedicated to this one particular feature. Otherwise the URLs would be ambiguous.

Share this post


Link to post
Share on other sites

thanks very much for that, i'll look into it now.  Am only going to be using it for the one page, and not using wordpress just that where i thought i'd seen something like it.

thanks again.

 :) 

Share this post


Link to post
Share on other sites

I feel like I need to emphasize the last thing I wrote a little bit more.

By using URLs like /ClientOrganizationName, where you have only one "segment" of the path, you are limiting what you can do in the future. Anything else that's one segment will look like a company name. That means you can't do stuff like /about or /Contact-Us because those will look like companies.

You should namespace the URL so that you can safely dedicate the entire pattern to companies without worrying about it conflicting with anything else. Doesn't have to be complicated. I'm thinking like /shop/ClientOrganizationName: you're able to add a new keyword in there and it's still easy for anyone to understand.

Share this post


Link to post
Share on other sites

thanks for your reply, i'll keep that in mind while implementing it, for now only intend on using it on one page, but i guess future proofing site couldn't hurt.

Share this post


Link to post
Share on other sites
2 hours ago, MsKazza said:

thanks for your reply, i'll keep that in mind while implementing it, for now only intend on using it on one page, but i guess future proofing site couldn't hurt.

It's really important to have a scheme like the one requinix is suggesting.  Let's consider it this way (without the rewriting)

 

#home page.  You can make this the default page by routing to home if there is no route parameter
index.php?route=home
#rewrite route
/home

#contact page
index.php?route=contact
#rewrite route
/contact

#faq
index.php?route=faq
#rewrite route
/faq

#faq item #3
index.php?route=faq&item=3
#rewrite route
/faq/3

#acme customer store page list of items
index.php?route=shop&customer=acme
#rewrite route
/shop/acme

#individual item #14 page in acme store
index.php?route=shop&customer=acme&item=14
#rewrite route
/shop/acme/14

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.