468,291 Members | 1,423 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,291 developers. It's quick & easy.

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!
Jun 30 '08 #1
8 1166
On Mon, 30 Jun 2008 13:56:28 -0400
edgy <ho*****@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 be******@NOSPAM.umn.edu>
Jun 30 '08 #2
On Jun 30, 2:28*pm, Michael Berkowski <berk0...@NOSPAMumn.eduwrote:
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.
Jul 1 '08 #3
edgy wrote:
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.
js*******@attglobal.net
==================

Jul 1 '08 #4
On Mon, 30 Jun 2008 17:21:28 -0700, netstreamer wrote:
On Jun 30, 2:28*pm, Michael Berkowski <berk0...@NOSPAMumn.eduwrote:
>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.
Jul 1 '08 #5
edgy wrote:
On Mon, 30 Jun 2008 17:21:28 -0700, netstreamer wrote:
>On Jun 30, 2:28 pm, Michael Berkowski <berk0...@NOSPAMumn.eduwrote:
>>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
Jul 2 '08 #6
On Tue, 01 Jul 2008 20:48:40 -0400
Jeff <jeff@spam_me_not.comwrote:
>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.
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
Jul 2 '08 #7
On Wed, 02 Jul 2008 08:40:18 -0500, Michael Berkowski wrote:
On Tue, 01 Jul 2008 20:48:40 -0400
Jeff <jeff@spam_me_not.comwrote:
<snip>
> 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?

Jul 2 '08 #8
edgy wrote:
On Wed, 02 Jul 2008 08:40:18 -0500, Michael Berkowski wrote:
>On Tue, 01 Jul 2008 20:48:40 -0400
Jeff <jeff@spam_me_not.comwrote:
<snip>
>> 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
Jul 2 '08 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by Sims | last post: by
5 posts views Thread by Abraham Lopez | last post: by
12 posts views Thread by prashna | last post: by
7 posts views Thread by André | last post: by
4 posts views Thread by mab464 | last post: by
reply views Thread by Teichintx | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.