Jump to content

switch array of users


vaskovasilev

Recommended Posts

Hello,

i am trying to make a calendar for different users which are described in the database.

depending on the link to earn a calendar for the user. here's the code:

 

$sql=" SELECT user , fullname FROM users ";
$resource=mysql_query($sql) or die(mysql_error());
while($array=mysql_fetch_assoc($resource))
{
$users[]=$array['user'];
}   
if (isset($_GET['user'])) {
$user = $_GET['user'];
setcookie('user', $user, time()+(3600*24*365));
}
elseif (isset($_COOKIE['user'])) {
$user = $_COOKIE['user'];
} else {
$user = 'bg';
}
if (!(in_array($user, array_keys($users)))) {
die("Грешка: няма езиков файл!");
}
require_once "{$user}.php";
function switch_users_options() {
global $text, $users, $user;
$retval = $text['switch'];
$get = $_GET;
foreach ($users as $abbrv => $name) {
if ($abbrv !== $user) {
$get['user'] = $abbrv;
$url = $_SERVER['PHP_SELF'] . '?' .
http_build_query($get);
$retval .= " <a href=\"{$url}\">
{$name}</a><br>";
}
}
return $retval;
}

 

I've taken it from one code to change the language ..

the question is that it displayed on new line - users from database but the links are wrong :

 

index.php?user=0, user=1 .. user=2

 

not as it should be index.php?user=user1, user=test ...

please for assistance.

Link to comment
https://forums.phpfreaks.com/topic/249706-switch-array-of-users/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.