Parsing arrays to another php-file?
Moderator: General Moderators
Parsing arrays to another php-file?
Hey there!
I have a html-page with a link to the same page (a sort-by-name-function). It shows a list of data from a database. My problem is, that every time I open the PHP-page the query will run again causing much action on my harddisk.
Is there anyway I can parse an array with the results from the database instead of running the database query again?
I have a html-page with a link to the same page (a sort-by-name-function). It shows a list of data from a database. My problem is, that every time I open the PHP-page the query will run again causing much action on my harddisk.
Is there anyway I can parse an array with the results from the database instead of running the database query again?
-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm
-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm
-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm
to pass an array from one php page to the other through POST/GET use serialize() and unserialize() functions. http://www.php.net/serialize for examples.
-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm
I'll make this quick since i do not have much time.
Sessions are used to keep state between pages, this is mostly used for a login system. If you store login information such as username, user preferances ..etc then that information will be required across all pages of your site. Thus Sessions are used. Although Sessions can pass non-state information acorss pages, it was not meant to serve that purpose as it is not efficient and niether is it logical. Thats why the Serialize function has been made.
Serialize has been specifically made for one purpose and one purpose alone. To pass vars, arrays and objects from one page to the other. This is information that you will need in only one single page, which is what the poster of this question wanted.
Using sessions in this way is certainly not "the best way". Cars and planes can get you to your desired destination, but each one is used in different situations.
Sessions are used to keep state between pages, this is mostly used for a login system. If you store login information such as username, user preferances ..etc then that information will be required across all pages of your site. Thus Sessions are used. Although Sessions can pass non-state information acorss pages, it was not meant to serve that purpose as it is not efficient and niether is it logical. Thats why the Serialize function has been made.
Serialize has been specifically made for one purpose and one purpose alone. To pass vars, arrays and objects from one page to the other. This is information that you will need in only one single page, which is what the poster of this question wanted.
Using sessions in this way is certainly not "the best way". Cars and planes can get you to your desired destination, but each one is used in different situations.