PDA

View Full Version : Using records and content for page templates


ajetrumpet
03-02-2010, 01:50 AM
all,

i am beginning with mysql and i would like to build a db driven site right the first time, so i don't have to deal with unnecessary changes in the future.

my question is simply: what is the general process for displaying web pages using content from a mysql database?

i have not done any research, and i'm not asking for PHP code to do this, but I simply want to know (in my mind's eye) how this stuff is done. Here are my assumptions:

***Webpage templates are created with layout objects on them (positioned accordingly), be it tables, frames, image placeholders, and whatever else.
***PHP is written to pull the content out of the record specified through the various fields, based on the query string in the URL.

if that is simply the case of how db websites work, it seems like a relatively painless process, but still a long one. is this how things generally work? and if so, are the controls on the webpage dynamically populated with the PHP code, or can the controls have some sort of "tag" attached to them (sort of like a bound field on an ACCESS form) that basically says, "display the content from field "A" based on the query string".

thanks for any input on this! appreciate it!

Old Pedant
03-02-2010, 02:36 AM
Yes.

<grin/>

In ordinary PHP, you just dump the content from the DB in place as needed, as you go down the page.

Example:

Name: <?php echo $name; /><br/>
Address: <?php echo $address; /><br/>
... etc. ...


Now, I am *not* a php person, at all. But with JSP and ASP.NET, there are frameworks where, indeed, you just use a tag and the association between tag and data happens for you. (This is especially true of ASP.NET. JSP, by default, works as I described for PHP--as does Classic ASP--but there are several different JSP frameworks that can make your code look a lot like ASP.NET.)

I'm *guessing* that there must be such a framework for PHP. Oh, wth. That's what google is for:
http://stackoverflow.com/questions/667382/which-php-framework-should-i-choose-between-zendframework-and-yii

So 3 good choices noted there. I'm sure there are more.

Note that the more you use a framework, the further removed you are from the gruntwork of programming. But also the further removed you can be from fine-grained control. So try to choose a framework that gives you the control you want with the efficiency of development you need.

Old Pedant
03-02-2010, 02:44 AM
Now a question: Why PHP??? Why not ASP.NET? You seem to be a Windows person. I think you may find that ASP.NET has a *lot* to offer.

Just as one example, you can tell it to configure a user login system for you, give it a few parameters, and WHAM! It creates the database, creates the <form>s, and more. (And then you'll fight with it trying to figure out how to use MySQL instead of SQL Server Express for the user info DB, but you won't be alone.) And ASP.NET's ability to display tabular data in most any way you can imagine is nothing short of amazing. But I will admit it's a moderately steep initial learning curve, though once you climb the first hill it gets a lot easier.

ajetrumpet
03-02-2010, 03:12 AM
Now a question: Why PHP??? Why not ASP.NET? You seem to be a Windows person. I think you may find that ASP.NET has a *lot* to offer.

Just as one example, you can tell it to configure a user login system for you, give it a few parameters, and WHAM! It creates the database, creates the <form>s, and more. (And then you'll fight with it trying to figure out how to use MySQL instead of SQL Server Express for the user info DB, but you won't be alone.) And ASP.NET's ability to display tabular data in most any way you can imagine is nothing short of amazing. But I will admit it's a moderately steep initial learning curve, though once you climb the first hill it gets a lot easier.

pedant,

i don't know ANY server side languages really, so it doesn't matter any which way as to what language I write my files in. I am familiar with SOME syntax in PHP, SOME conventions, and I have the code on other pages I've programmed that I can pull portions out of to make writing this site less time consuming. ASP.net is something I don't know anything about, but if you ask me, any server side language sucks in terms of the complexity you have to put up with.

by the way, what's the difference between ASP and it's sister .NET? I assume to program in either one you need an ASP extension on your page name.

as far as my choice of language, I simply more time in front of the computer staring at PHP syntax than any others, thus it is my choice. :rolleyes:

Old Pedant
03-02-2010, 07:04 AM
Well, PHP is really just a derivative of C, so any of the C-derived languages will at least feel similar. JavaScript, of course, but then Java or C#.

There's no more similarity between Classic ASP and ASP.NET than there is between, say, Java and JavaScript. Some similarities, but none that really matter. Classic ASP uses ".asp" extension, ASP.NET uses ".aspx" extension.

if you ask me, any server side language sucks in terms of the complexity you have to put up with.
<shrug>Then don't code server side.</shrug>

It's not the languages that are complex, in any case, it's the platforms. Moving from C# to PHP to JavaScript to Java to C++ ... no big deal. Moving from platofrm to platform: Huge pain. Have to learn the APIs and object models and and and. But, honestly, I don't think old-style PHP or Classic ASP (either one) are anywhere near as much trouble to learn as, say, a full understanding of the DOM as it applies to the four major browser models. Just as a point of comparison.