473,320 Members | 1,732 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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 1315
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Sims | last post by:
Hi I have a table with something like ID PARENT 0 | -1 1 | -1 2 | 1 3 | 1
7
by: Peter Rooney | last post by:
Hi, I have 24 checkboxes all with the same naming convention, each box has a value ranging from 1 to 23, what I need to do is fill in the gaps with a 0 value where the user doesn't select a...
5
by: Abraham Lopez | last post by:
Hi.. Is there a way to convert a System.Array to XML... If you know thanks very much... if you don't... Please do not respond stupid things like " Yes -- many ways."
12
by: prashna | last post by:
Hi Guru's, Here are my questions... 1)Why does c allows an extra "," in array intialiser?Is there any advantage of this? ex: int arr={1,2,3,4,5,}; ^^Compiler does not give error for this! ...
14
by: romayankin | last post by:
Hello All, I'm writing cross-platform code so i'm bound to standards. Here is the code I have: ~~~~~~~~~~~~~~~~~~ double **mx = new double*; for(int i = 0; i < col - 1; i++) { mx = new...
7
by: André | last post by:
Hi, I need several cookies depending of an variable (x), so i defined a HttpCookie() as an array. My problems: 1)I get the error: Object reference not set to an instance of an object. 2)My...
10
by: SM | last post by:
Hello I'm trying to create a multi dimensional array in JavaScript, but after some reading i still can't figure out how to apply it to my model. Here it is: I have a list A and for each item...
1
by: Kurt Jakobsen | last post by:
Hello, I have a MySQL query that I want to perform in a utility (not page) class. This query should fill up an array of string's and then return the array to the calling class. The array will then...
4
by: mab464 | last post by:
I have this code on my WAMP server running on my XP machine if ( isset( $_POST ) ) { for($i=0; $i<count($_POST);$i++) { if ($ans != NULL ) $ans .= ", " . $_POST ; // Not the first...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.