werepea Posted July 28, 2005 Posted July 28, 2005 I just began my approach on learning PHP and MySQL. I recently just created my first database, username, blah via cpanel and still messing around with it. I've seen alot of sites that network all their links via php. Sometimes I see links on sites that look like this: http://www.addresshere.com?index.php?files=link How do designers/webmasters organize their sites so that links tend to direct like that? Is it using databases with MySQL or what? Quote
Deverill Posted July 28, 2005 Posted July 28, 2005 Not necessarily, but possibly. On one of my sites I have the framework, links, headers, etc all in one php file named index.php. In that, at the appropriate place I have a statement in PHP coding that says to include the contents of a file named in the variable FILE. This lets me have just the interior content of a page in a file named aboutus.htm and the framework is in only one file instead of 70. On my links I just enter mytchsite.com/index.php?file=aboutus.htm and I get the framework from index.php and the "guts" of the site from the small file aboutus.htm If it is a catalog type site then they can do the same thing but the photos of the items and the descriptions are usually in mySQL databases instead of separate files. Quote
werepea Posted July 29, 2005 Author Posted July 29, 2005 Not necessarily, but possibly. On one of my sites I have the framework, links, headers, etc all in one php file named index.php. In that, at the appropriate place I have a statement in PHP coding that says to include the contents of a file named in the variable FILE. This lets me have just the interior content of a page in a file named aboutus.htm and the framework is in only one file instead of 70. On my links I just enter mytchsite.com/index.php?file=aboutus.htm and I get the framework from index.php and the "guts" of the site from the small file aboutus.htm If it is a catalog type site then they can do the same thing but the photos of the items and the descriptions are usually in mySQL databases instead of separate files. <{POST_SNAPBACK}> I see. I'm interested in how you do that. How do you just have 1 index page and have external information come from just putting ?file=blahblah at the end of a link? I'm very curious and I want to start organizing my websites like that. Quote
TCH-Don Posted July 29, 2005 Posted July 29, 2005 One of our family members Surfire, just posted a link to this very subject Php Templating Article, Beginners, but pretty solid Quote
werepea Posted July 29, 2005 Author Posted July 29, 2005 http://www.thinkmakeprint.com/phptest/test/main.php doesn't work for me ? :/ i downloaded the actual demonstration zip, i extracted it , and uploaded it to my ftp and iit doesn't work :/ any help? One of our family members Surfire,just posted a link to this very subject Php Templating Article, Beginners, but pretty solid <{POST_SNAPBACK}> Quote
TCH-Don Posted July 29, 2005 Posted July 29, 2005 When I clicked on your link, it works for me. Quote
werepea Posted July 29, 2005 Author Posted July 29, 2005 When I clicked on your link,it works for me. <{POST_SNAPBACK}> ya it works now :/ for some odd reason . oh well . also, how do i make it so when i click on certain links, the title will change to the subject of that page. Quote
surefire Posted July 29, 2005 Posted July 29, 2005 (edited) In my post I mentioned that the article was a little basic. But I liked the fact that it seemed to be built on sound principles. I see a lot of people that are learning PHP discover a new tool but aren't told how to use it safely and to take steps that would prevent attacks. The article doesn't address some obvious things you'd want in a templating system, as you have pointed out. To answer your question, there are several ways to skin a cat. I would put the html from the 'main' file (in the tutorial referenced) into the header file. This way you could do something like ><title><? echo $site_title; ?></title> How you set the site_title variable just depends on your coding style and what you're comfortable with. I'd probably take the simple array given in the tutorial and turn it into a more detailed associative array where the title was contained in the array. But, in all honesty, I wouldn't use this templating system as it's written. It's a good starting point for you to learn how to build templating systems. Specifically, it defines in advance a finite number of possibilities for the PHP to include into the code. This is a safety feature that is missing from templates built by beginners. Edited July 29, 2005 by surefire Quote
werepea Posted July 30, 2005 Author Posted July 30, 2005 In my post I mentioned that the article was a little basic. But I liked the fact that it seemed to be built on sound principles. I see a lot of people that are learning PHP discover a new tool but aren't told how to use it safely and to take steps that would prevent attacks. The article doesn't address some obvious things you'd want in a templating system, as you have pointed out. To answer your question, there are several ways to skin a cat. I would put the html from the 'main' file (in the tutorial referenced) into the header file. This way you could do something like ><title><? echo $site_title; ?></title> How you set the site_title variable just depends on your coding style and what you're comfortable with. I'd probably take the simple array given in the tutorial and turn it into a more detailed associative array where the title was contained in the array. But, in all honesty, I wouldn't use this templating system as it's written. It's a good starting point for you to learn how to build templating systems. Specifically, it defines in advance a finite number of possibilities for the PHP to include into the code. This is a safety feature that is missing from templates built by beginners. <{POST_SNAPBACK}> do you know of anymore tutorial sites / walkthrough guides like the first one you gave out . im interested to see how the same concept can be "skinned.." and maybe help me understand the concept more Quote
carbonize Posted July 30, 2005 Posted July 30, 2005 I hate to sound nasty but it sounds like they have tried to run before learning to walk. You should learn more about the basics of PHP (includes, variables, GPC etc) before starting on MySQL. A good solid base is a must for anything. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.