TheSky Posted May 11, 2011 Share Posted May 11, 2011 im doing it wrong can some one help me ? , thanks { define('userlevel'( 9="admin" , 1="guest")); } Quote Link to comment https://forums.phpfreaks.com/topic/236118-doing-define-wrong/ Share on other sites More sharing options...
wildteen88 Posted May 11, 2011 Share Posted May 11, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/236118-doing-define-wrong/#findComment-1213906 Share on other sites More sharing options...
TheSky Posted May 11, 2011 Author Share Posted May 11, 2011 <?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++; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/236118-doing-define-wrong/#findComment-1213917 Share on other sites More sharing options...
wildteen88 Posted May 11, 2011 Share Posted May 11, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/236118-doing-define-wrong/#findComment-1213938 Share on other sites More sharing options...
TheSky Posted May 11, 2011 Author Share Posted May 11, 2011 yes i got it but now i need 1. username (here is status) but i get K�lalineAdministraatorK�lalineK�laline all in same row is there $somevalue possible ? Quote Link to comment https://forums.phpfreaks.com/topic/236118-doing-define-wrong/#findComment-1213957 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.