Forum Moderators: coopster

Message Too Old, No Replies

Arrays v database (php and Mysql)

         

Flolondon

11:44 pm on Feb 5, 2005 (gmt 0)

10+ Year Member



Hi. there can someone please tell me what is the difference between arrays and database...in php

thanks...

grandpa

12:55 am on Feb 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I'll give it a go.

Even though you specified in PHP, there is typically no difference in these between any language.
In other words, an array is still an array, whether written in C, Pascal or PHP.

An array is a collection of items. Defined in the program, it can then be added to or have items removed. It can be read after adding items, and decisions may be based on the array content. To create an array is PHP is simple: $myArray = array(); That created an array called $myArray. My most common usage of an array would be to read data from a table and populate the array elements, where I can then act on that data. After that, I use array to define standard items; for example, I would create an array to hold the values of shipping methods .

A database is quite different. It is a defined area, an object, if you will, that is defined outside your program. A database will contain tables, and those tables will contain your data. (I need help with my definition..)

You access a table in a database to either add a row, delete a row, or change an existing row.

You can populate an array with table data, likewise you can populate a table from an array.

The last bit I could add: From a programming point of view, an array is dynamic, created at the time the program executes. When the program is completed, the array no longer exists. A database, as an object, must be defined before a program can access it.

Flolondon

8:25 am on Feb 6, 2005 (gmt 0)

10+ Year Member



thanx