Jump to content

Recommended Posts

im doing it wrong can some one help me ? , thanks

{

define('userlevel'( 9="admin" , 1="guest"));

}

It helps if you tell use what you're trying to do with it.

 

The function define is used to create constants. Constants are like variables expect you cannot change their values once you have created them. I don't think this is the function you want to use.

 

I think what you're trying to do is associate a users userlevel with a title, eg  when a user has a userlevel of 9 give them the title of admin. If it is 1 give them a title of guest.

 

Link to comment
https://forums.phpfreaks.com/topic/236118-doing-define-wrong/#findComment-1213906
Share on other sites

<?php
include("xxxx.php");
$sql=mysql_query("SELECT * FROM users ORDER BY userid DESC LIMIT 0,5") or die(mysql_error());
$x=0;
while($row=mysql_fetch_array($sql))
{
($x+1).'. '.$row['username'].'.  kasutaja tüüp  '.$row['userlevel'].'<br />';
//let's add some define values
define('userlevel');

if(defined('1')) {
  echo Külaline . '<br />';
}

if(defined('9')) {
  echo Administraator . '<br />';
}
$x++;
}
?>

Link to comment
https://forums.phpfreaks.com/topic/236118-doing-define-wrong/#findComment-1213917
Share on other sites

You'll want to use a switch statement. Not define.

switch($row['userlevel'])
{
    case 1:
        echo 'Külaline';
    break;
    
    case 9:
        echo 'Administraator';
    break;
}

When $row['userlevel'] is 1 it'll echo Külaline.

When $row['userlevel'] is 9 it'll echo Administraator.

Link to comment
https://forums.phpfreaks.com/topic/236118-doing-define-wrong/#findComment-1213938
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.