Php/mysql Databasing

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.<br /><br />Sometimes I see links on sites that look like this:<br /><a href="http://www.addresshere.com?index.php?files=link" target="_blank">http://www.addresshere.com?index.php?files=link</a><br /><br />How do designers/webmasters organize their sites so that links tend to direct like that? Is it using databases with MySQL or what?<!--content-->
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<br /><br />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.<!--content-->
<!--QuoteBegin-TCH-Jim+Jul 28 2005, 11:04 AM--><div class='quotetop'>QUOTE(TCH-Jim @ Jul 28 2005, 11:04 AM)</div><div class='quotemain'><!--QuoteEBegin-->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<br /><br />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.<br /><div align="right"><a href="http://www.totalchoicehosting.com/forums/index.php?act=findpost&pid=141744"><img src='http://www.totalchoicehosting.com/forums/style_images/1/post_snapback.gif' alt='*' border='0' /></a></div><!--QuoteEnd--></div><!--QuoteEEnd--><br /><br /><br /><br />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.<!--content-->
One of our family members Surfire,<br />just posted a link to this very subject<br /><br /><a href="http://www.totalchoicehosting.com/forums/index.php?showtopic=21498&st=0&p=141260&#entry141260" target="_blank">Php Templating Article, Beginners, but pretty solid</a><!--content-->
<a href="http://www.thinkmakeprint.com/phptest/test/main.php" target="_blank">http://www.thinkmakeprint.com/phptest/test/main.php</a><br /><br />doesn't work for me ? :/<br />i downloaded the actual demonstration zip, i extracted it , and uploaded it to my ftp and iit doesn't work :/ any help?<br /><br /><br /><br /><br /><br /><!--QuoteBegin-TCH-Don+Jul 28 2005, 08:58 PM--><div class='quotetop'>QUOTE(TCH-Don @ Jul 28 2005, 08:58 PM)</div><div class='quotemain'><!--QuoteEBegin-->One of our family members Surfire,<br />just posted a link to this very subject<br /><br /><a href="http://www.totalchoicehosting.com/forums/index.php?showtopic=21498&st=0&p=141260&#entry141260" target="_blank">Php Templating Article, Beginners, but pretty solid</a><br /><div align="right"><a href="http://www.totalchoicehosting.com/forums/index.php?act=findpost&pid=141808"><img src='http://www.totalchoicehosting.com/forums/style_images/1/post_snapback.gif' alt='*' border='0' /></a></div><!--QuoteEnd--></div><!--QuoteEEnd--><!--content-->
When I clicked on your link,<br />it works for me. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/blink.gif" style="vertical-align:middle" emoid=":blink:" border="0" alt="blink.gif" /><!--content-->
<!--QuoteBegin-TCH-Don+Jul 29 2005, 01:10 AM--><div class='quotetop'>QUOTE(TCH-Don @ Jul 29 2005, 01:10 AM)</div><div class='quotemain'><!--QuoteEBegin-->When I clicked on your link,<br />it works for me. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/blink.gif" style="vertical-align:middle" emoid=":blink:" border="0" alt="blink.gif" /><br /><div align="right"><a href="http://www.totalchoicehosting.com/forums/index.php?act=findpost&pid=141832"><img src='http://www.totalchoicehosting.com/forums/style_images/1/post_snapback.gif' alt='*' border='0' /></a></div><!--QuoteEnd--></div><!--QuoteEEnd--><br /><br /><br /><br />ya it works now :/ for some odd reason . oh well . <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /><br />also, how do i make it so when i click on certain links, the title will change to the subject of that page.<!--content-->
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.<br /><br />The article doesn't address some obvious things you'd want in a templating system, as you have pointed out.<br /><br />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<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><title><? echo $site_title; ?></title><!--c2--></div><!--ec2--><br /><br />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.<br /><br />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.<!--content-->
<!--QuoteBegin-surefire+Jul 29 2005, 09:51 AM--><div class='quotetop'>QUOTE(surefire @ Jul 29 2005, 09:51 AM)</div><div class='quotemain'><!--QuoteEBegin-->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.<br /><br />The article doesn't address some obvious things you'd want in a templating system, as you have pointed out.<br /><br />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<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><title><? echo $site_title; ?></title><!--c2--></div><!--ec2--><br /><br />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.<br /><br />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.<br /><div align="right"><a href="http://www.totalchoicehosting.com/forums/index.php?act=findpost&pid=141884"><img src='http://www.totalchoicehosting.com/forums/style_images/1/post_snapback.gif' alt='*' border='0' /></a></div><!--QuoteEnd--></div><!--QuoteEEnd--><br /><br /><br /><br /><br /><br />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<!--content-->
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.<!--content-->
 
Back
Top