Forum Moderators: coopster
i've currently got the following code that basically provides different values for the following variables: $start,$lunch & $end.
so if username1 equals user1 then the values are specified else if the username1 equals user2 then another set of values etc...
because these users will be ammended from time to time, i dont want to edit the code everytime and want to know how i can make the code below work by fetching data from a text file that has each user in 1 line with the variables set in the text file?
if ($username1=="user1") {
$start = "900";
$lunch = "1200";
$end = $normal;
}
elseif ($username1=="user2") {
$start = "800";
$lunch = "1200";
$end = "400";
}
else {
$start = "900";
$lunch = "1200";
$end = $normal;
}
-----
$include_file = $username1 . '.txt';
include($include_file);
----
and then have separate files for each user
**** user1.txt
<?php
$start = "900";
$lunch = "1200";
$end = $normal;
?>
****
**** user2.txt
<?php
$start = "800";
$lunch = "1200";
$end = "400";
?>
****
That would be fine for not too many files but if there are many you may want to incorporate into one larger file. Bigger than that then a database would be a better option.
[edited by: Frank_Rizzo at 11:24 am (utc) on June 25, 2009]