
June 30th, 2008, 07:05 PM
|
|
|
php array used to fill in a web page
First off, my skill level is beginner/intermediate.
I know how to use php/mysql to fill in a page with information, but I read
a little about arrays and i think this may be an interesting and easy way
to maintain a small website.
My idea is to have all the titles, descriptions, etc in one php document
in an array and then pull from that for the different pages.
Do you recommend this? In your experience is this less or more work in
the long run for a small website that does, perhaps, monthly maintenance?
Are there other issues I am not aware of?
As well, googling has not led me to a good tutorial on this. Could anyone
point me at one?
Thanks!
|

June 30th, 2008, 07:35 PM
|
|
|
Re: php array used to fill in a web page
On Mon, 30 Jun 2008 13:56:28 -0400
edgy <hotmail@notmail.comwrote:
Quote:
Do you recommend this? In your experience is this less or more work in
the long run for a small website that does, perhaps, monthly maintenance?
Are there other issues I am not aware of?
>
|
Last year, I was given the task of maintaining a small website designed
similarly to how you've described, with blocks of content stored in a
large array. I strongly recommend against this type of architecture,
as it requires the whole array to load every time you access a page
(which means parsing all your content even though you only need one
chunk). I ended up rewriting most of the site's PHP to elminate the
array architecture.
--
Michael berk0081@NOSPAM.umn.edu>
|

July 1st, 2008, 01:25 AM
|
|
|
Re: php array used to fill in a web page
On Jun 30, 2:28*pm, Michael Berkowski <berk0...@NOSPAMumn.eduwrote:
Quote:
On Mon, 30 Jun 2008 13:56:28 -0400
>
edgy <hotm...@notmail.comwrote:
Quote:
Do you recommend this? *In your experience is this less or more work in
the long run for a small website that does, perhaps, monthly maintenance?
Are there other issues I am not aware of?
|
>
Last year, I was given the task of maintaining a small website designed
similarly to how you've described, with blocks of content stored in a
large array. *I strongly recommend against this type of architecture,
as it requires the whole array to load every time you access a page
(which means parsing all your content even though you only need one
chunk). *I ended up rewriting most of the site's PHP to elminate the
array architecture.
--
Michael berk0...@NOSPAM.umn.edu>
|
I think for a small site it's a pretty good idea, but you may as well
keep the information in a central file and load it into an array. You
can use some XML for that. I've used this sort of architecture before
not only to be able to easily alter headers, but to build a whole wiki-
like system for one of my clients so that she could alter her website
content easily.
|

July 1st, 2008, 01:45 AM
|
|
|
Re: php array used to fill in a web page
edgy wrote:
Quote:
First off, my skill level is beginner/intermediate.
>
I know how to use php/mysql to fill in a page with information, but I read
a little about arrays and i think this may be an interesting and easy way
to maintain a small website.
>
My idea is to have all the titles, descriptions, etc in one php document
in an array and then pull from that for the different pages.
>
Do you recommend this? In your experience is this less or more work in
the long run for a small website that does, perhaps, monthly maintenance?
Are there other issues I am not aware of?
>
As well, googling has not led me to a good tutorial on this. Could anyone
point me at one?
>
Thanks!
>
|
You probably didn't find a good tutorial on it because it doesn't work
all that well. Sure, you can do it. But performance won't be that good.
Sure, it's a small website *now*. But it will either grow or stagnate.
If it stagnates, it doesn't matter what you do - no one will be
looking, anyway. But if it grows, you'll run into problems maintaining
it - and probably sooner rather than later.
It isn't that hard to create a site which can expand easily. Or look
for one of the templating systems around.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
|

July 1st, 2008, 03:05 PM
|
|
|
Re: php array used to fill in a web page
On Mon, 30 Jun 2008 17:21:28 -0700, netstreamer wrote:
Quote:
On Jun 30, 2:28*pm, Michael Berkowski <berk0...@NOSPAMumn.eduwrote:
Quote:
>On Mon, 30 Jun 2008 13:56:28 -0400
>>
>edgy <hotm...@notmail.comwrote:
Quote:
Do you recommend this? *In your experience is this less or more work in
the long run for a small website that does, perhaps, monthly maintenance?
Are there other issues I am not aware of?
|
>>
>Last year, I was given the task of maintaining a small website designed
>similarly to how you've described, with blocks of content stored in a
>large array. *I strongly recommend against this type of architecture,
>as it requires the whole array to load every time you access a page
>(which means parsing all your content even though you only need one
>chunk). *I ended up rewriting most of the site's PHP to elminate the
>array architecture.
>--
>Michael berk0...@NOSPAM.umn.edu>
|
>
I think for a small site it's a pretty good idea, but you may as well
keep the information in a central file and load it into an array. You
can use some XML for that. I've used this sort of architecture before
not only to be able to easily alter headers, but to build a whole wiki-
like system for one of my clients so that she could alter her website
content easily.
|
Thanks for the responses. I guess I will do it by storing the info in a
mysql database then.
|

July 2nd, 2008, 01:55 AM
|
|
|
Re: php array used to fill in a web page
edgy wrote:
Quote:
On Mon, 30 Jun 2008 17:21:28 -0700, netstreamer wrote:
>
Quote:
>On Jun 30, 2:28 pm, Michael Berkowski <berk0...@NOSPAMumn.eduwrote:
Quote:
>>On Mon, 30 Jun 2008 13:56:28 -0400
>>>
>>edgy <hotm...@notmail.comwrote:
>>>Do you recommend this? In your experience is this less or more work in
>>>the long run for a small website that does, perhaps, monthly maintenance?
>>>Are there other issues I am not aware of?
>>Last year, I was given the task of maintaining a small website designed
>>similarly to how you've described, with blocks of content stored in a
>>large array. I strongly recommend against this type of architecture,
>>as it requires the whole array to load every time you access a page
>>(which means parsing all your content even though you only need one
>>chunk). I ended up rewriting most of the site's PHP to elminate the
>>array architecture.
>>--
>>Michael berk0...@NOSPAM.umn.edu>
|
>I think for a small site it's a pretty good idea, but you may as well
>keep the information in a central file and load it into an array. You
>can use some XML for that. I've used this sort of architecture before
>not only to be able to easily alter headers, but to build a whole wiki-
>like system for one of my clients so that she could alter her website
>content easily.
|
>
>
Thanks for the responses. I guess I will do it by storing the info in a
mysql database then.
|
No, it doesn't have to be in a database. Myself, I serialize the data
and store it in a small file associated with that page. YMMV.
Jeff
|

July 2nd, 2008, 02:45 PM
|
|
|
Re: php array used to fill in a web page
On Tue, 01 Jul 2008 20:48:40 -0400
Jeff <jeff@spam_me_not.comwrote:
Quote:
Quote:
Quote:
>Last year, I was given the task of maintaining a small website designed
>similarly to how you've described, with blocks of content stored in a
>large array. I strongly recommend against this type of architecture,
>as it requires the whole array to load every time you access a page
>(which means parsing all your content even though you only need one
>chunk). I ended up rewriting most of the site's PHP to elminate the
>array architecture.
|
|
|
Quote:
No, it doesn't have to be in a database. Myself, I serialize the data
and store it in a small file associated with that page. YMMV.
>
Jeff
|
Agreed. In the application I mentioned above, I rewrote it to
serialize into a file per page. A database would have been overkill
since it would likely never grow beyond a dozen or so pages. As Jeff
suggested, YMMV.
-Michael
|

July 2nd, 2008, 05:25 PM
|
|
|
Re: php array used to fill in a web page
On Wed, 02 Jul 2008 08:40:18 -0500, Michael Berkowski wrote:
Quote:
On Tue, 01 Jul 2008 20:48:40 -0400
Jeff <jeff@spam_me_not.comwrote:
>
|
<snip>
Quote:
Quote:
> Myself, I serialize the data
>and store it in a small file associated with that page. YMMV.
>>
> Jeff
|
>
Agreed. In the application I mentioned above, I rewrote it to serialize
into a file per page. A database would have been overkill since it
would likely never grow beyond a dozen or so pages. As Jeff suggested,
YMMV.
>
-Michael
|
Ok, this seems interesting. Googling turns up lots of examples of
interactive applications that use serialize/unserialize - could you point
me to an example of what you did?
|

July 2nd, 2008, 06:15 PM
|
|
|
Re: php array used to fill in a web page
edgy wrote:
Quote:
On Wed, 02 Jul 2008 08:40:18 -0500, Michael Berkowski wrote:
>
Quote:
>On Tue, 01 Jul 2008 20:48:40 -0400
>Jeff <jeff@spam_me_not.comwrote:
>>
|
<snip>
>
Quote:
Quote:
>> Myself, I serialize the data
>>and store it in a small file associated with that page. YMMV.
>>>
>> Jeff
|
>Agreed. In the application I mentioned above, I rewrote it to serialize
>into a file per page. A database would have been overkill since it
>would likely never grow beyond a dozen or so pages. As Jeff suggested,
>YMMV.
>>
>-Michael
|
>
Ok, this seems interesting. Googling turns up lots of examples of
interactive applications that use serialize/unserialize - could you point
me to an example of what you did?
>
|
Just look through the php docs, you'll see the serialize and unserialize
functions.
There's a lot of ways to go about this. I prefer to store page paths
(and other non content info) in a database. That way I have the site
structure and I can mark pages as being online/offline, etc out of that
and create my navigation from the database. I tend to work with sites
that have many directories and pages.
I prefer to write .html pages and use a template. That way if I wanted
to either add a page or change the look, I use one of the templates.
This is what is called a "Content Management System", or CMS for short.
It can be as simple or as complex as you wish it to be. You may wish to
use one of the open source CMS's out there. There are gotchas in the
details and those should have that covered already.
If you chose to do this, do it in a way that is easily expandable.
Look at the data you have, and then figure out the data structure. The
more thought up front, the less work later fixing what you overlooked.
And throw in some slack as something always pops up later!
Jeff
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
What is Bytes?
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over network members.
|