set values once

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
let say that i want to allow someone (the site admin maybe) to chose
certain configuration values, for instance

* number of products per page
* picture widht
* back color

Right now, i just have all those info in a php page, so it can't be
$number of products_per_page = 20;
$picture_widht = 2;
$back_color = #FFFFFF;

I could keep this info in the database, but i should read it every time
a page is rendered... (open connection, query, close conn)

What would be the best way to do what i'm need? Is there any chance to
"read once, keep value for ever" ?

regards - jm

Re: set values once


//I would use sessions or cookies... or you could turn on globals but i
wouldn't recommend this...


$back_color = #FFFFFF;
$_SESSION['back_color'] = $back_color;

<body bgcolor='<? echo $_SESSION['back_color']; ?>'>

// I hope this helps
// from,
// pizzy

Re: set values once

But this is mainly what i'm doing right now. Note that #FFFFFF is
"static" and can't be changed without have access to .php file...

I should try to see how products like os_commerce or the like solve
this kind of things...

Re: set values once

right... you want to story users info so that when they log back in
their settings are kept... use a database for this and query as soon as
they login. then use my examples to display his or her values.

Re: set values once

julian_m wrote:

Quoted text here. Click to load it
Quoted text here. Click to load it

So put it in a file then (although it's not *that* much of an overhead using
the DB):

file_put_contents($config_file, serialize($options));




Site Timeline