Page 1 of 1

Question regarding URLS and PHP Code

Posted: Wed May 16, 2012 8:47 am
by mcc_shane
Hi Everyone,

Before I ask my question I would like to give everyone a background on myself. I'm currently in the learning stages of PHP and MySql.

(I apol. in advance for my lack of tech. terminology)

I have a question regarding how to "make" or "produce" certain pages in php code. In my past I've always manually made a pages. For example, aboutus.html, information.html, cats.html etc ... I think you get the idea.

Assuming code is being used. How would one go about "making" or "producing" pages that are fully functional php pages? Where people can log in, make edits, write reviews etc ... (a few examples are below)

Do the owners/programmers of the below websites manually "make" or "produce" these pages?
http://cars.oodle.com/used-cars/san-jose-ca-area/
http://www.yelp.com/biz/lotus-of-siam-las-vegas
http://restaurants.uptake.com/californi ... 17137.html
http://www.yelp.com/c/san-jose/restaurants

My question is, how can I "make" or "produce" these types of pages for my website? Can anyone offer my any tips/tricks on how to do so. All opinions welcome. Thanks everyone in advance for the help.

Re: Question regarding URLS and PHP Code

Posted: Wed May 16, 2012 8:57 am
by Celauran
The sites listed aren't terribly similar. What is it exactly you're trying to accomplish?

Re: Question regarding URLS and PHP Code

Posted: Wed May 16, 2012 9:39 am
by Grizzzzzzzzzz
mcc_shane wrote:Hi Everyone,
My question is, how can I "make" or "produce" these types of pages for my website? Can anyone offer my any tips/tricks on how to do so. All opinions welcome. Thanks everyone in advance for the help.
a common & easy way that people do this kind of thing (like on this url you linked http://cars.oodle.com/used-cars/san-jose-ca-area/) will be to have many dummy pages, that include a 'mother file'

for example within the used-cars folder, they'll have many php files such as

san-jose.php
fresno.php
napa.php
etc....

all of which simply have something like this in them

Code: Select all

<?php
include("example_mother_file.php");
?>
the example_mother_file.php will have a basic layout in it that's present across all pages of that type, along with some code near the beginning which parses the URL and performs a search based on that.

So for example when a user navigates to the san-jose.php page, 'San Jose' will be retrieved & stored as a variable, and a database will be queried for all cars in that area and the results will be displayed.

It's the same principle as a web forum, but instead of using forum ids, thread ids, page numbers as identifiers, it uses a location. To get a better understanding on how pages are dynamically created using stuff like that, read through something like a php forum creation tutorial

Re: Question regarding URLS and PHP Code

Posted: Wed May 16, 2012 9:53 am
by Celauran
That tutorial is hilariously bad. It's like a collection of worst practices and ought to be avoided.

Re: Question regarding URLS and PHP Code

Posted: Wed May 16, 2012 10:43 am
by mcc_shane
Hi Grizzzzzzzzzz and Celauran.

Thanks for the responses.
"The sites listed aren't terribly similar. What is it exactly you're trying to accomplish?"
(the below page would be the page I'm trying to emulate)
http://cars.oodle.com/used-cars/san-jose-ca-area/

What I'm trying to do is to extract data from my database (MySql) and use that data to "make" or "produce" certain pages on my website. That data would also be used in my URLS and meta tags.

Grizzzzzzzzzz repsone was accurate in what I'm trying to accomplish but I have no idea or where I start regarding how actually do it. Can this be done best via a website CMS? or am I completely off with that question.

Grizzzzzzzzzz provided a URL link for a tutorial but I guess it's not every good. Perhaps someone else has a better tutorial?

Thanks everyone!

Re: Question regarding URLS and PHP Code

Posted: Thu May 17, 2012 3:42 am
by Grizzzzzzzzzz
Celauran wrote:That tutorial is hilariously bad. It's like a collection of worst practices and ought to be avoided.
definately, but it's the most basic of the basic. Click on forum, returns children threads, click on thread and return children posts.

It doesn't cover anything like escaping data, optimisation & it unnecessarily repeats codes ad nausea.

But as far as demonstrating the basic principle of displaying dynamic pages with the use of URLs, i'd say it easily does the job


In regards to doing it yourself mcc_shane, it depends on what you're trying to accomplish. If it's personal project, or something similar to a blog, i'd recommend looking into using a CMS, something like WordPress which handles everything for you.

If your project needs to be abit more bespoke then I'd recommend searching for a few php tutorials on building forums/dynamic pages, as that'll lead you in the right direction and give you a general idea of how it all works. I certainly wouldn't recommend that tutorial I posted being taken to a commercial level, but it's easily good enough to take you through the very basics.

There are plenty of other CMSs out there though, built for all different kinds of purposes, so i imagine there will probably be one for this exact purpose.