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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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