Connecting Tech Pros Worldwide Help | Site Map

set values once

  #1  
Old September 30th, 2005, 02:25 AM
julian_m
Guest
 
Posts: n/a
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
modified
$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

  #2  
Old September 30th, 2005, 03:05 AM
pizzy
Guest
 
Posts: n/a

re: set values once


//jm,

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

//example:

//////////////////////
//(index.php)
///////////////////////
session_start();
$back_color = #FFFFFF;
$_SESSION['back_color'] = $back_color;

//////////////////////
//(nextPage.php)
///////////////////////
session_start();
<body bgcolor='<? echo $_SESSION['back_color']; ?>'>


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

  #3  
Old September 30th, 2005, 03:15 AM
julian_m
Guest
 
Posts: n/a

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...

  #4  
Old September 30th, 2005, 03:25 AM
pizzy
Guest
 
Posts: n/a

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.

  #5  
Old September 30th, 2005, 09:45 AM
Colin McKinnon
Guest
 
Posts: n/a

re: set values once


julian_m wrote:
[color=blue]
> let say that i want to allow someone (the site admin maybe) to chose
> certain configuration values, for instance[/color]
<snip>[color=blue]
>
> I could keep this info in the database, but i should read it every time
> a page is rendered... (open connection, query, close conn)
>[/color]

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));

and

$options=unserialize(file_get_contents($config_fil e));

C.
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Image does not move to set location kidko answers 5 June 19th, 2008 10:56 AM
Property values disappear on postback stephen answers 8 August 16th, 2006 08:25 PM
Use code to set values of webform and submit Mark answers 4 November 18th, 2005 04:31 AM
Return field values from a query using a Recordset in VBA bdt513 answers 19 November 13th, 2005 06:18 AM