Simon180 Posted October 3, 2007 Share Posted October 3, 2007 ok I would like to know how to make a simple rank system that reads the current rank number from a database then adds it to a rank arrays like so: // account ranks settings $ranks = array( 0=> "FREE Package", 1=> "Employee"); would then show the rank title in a page or link can anyone help me please? thanks Quote Link to comment https://forums.phpfreaks.com/topic/71719-arrays-help/ Share on other sites More sharing options...
MmmVomit Posted October 3, 2007 Share Posted October 3, 2007 What does your query look like? Quote Link to comment https://forums.phpfreaks.com/topic/71719-arrays-help/#findComment-361114 Share on other sites More sharing options...
Simon180 Posted October 3, 2007 Author Share Posted October 3, 2007 $sql = "SELECT username FROM accounts WHERE userlevel"; $result = mysql_query($sql); $ranks = mysql_fetch_array($result); $ranks["userlevel"]; Quote Link to comment https://forums.phpfreaks.com/topic/71719-arrays-help/#findComment-361170 Share on other sites More sharing options...
MmmVomit Posted October 3, 2007 Share Posted October 3, 2007 "WHERE userlevel" what? A where clause is used to limit which records are returned, for example $sql = "SELECT username FROM accounts WHERE userlevel = 0"; Also, the userlevel will not be returned in that query. To get the username and the userlevel, you would need something like this. <?php $sql = "SELECT username FROM accounts"; $result = mysql_query($sql); $ranks = mysql_fetch_array($result); // Because the only column in the select clause is "username" // $ranks will be an array with only one index, being "username" $ranks["userlevel"]; // This will throw a Notice level error ?> You need something like this. <?php $sql = "SELECT username, userlevel FROM accounts"; $result = mysql_query($sql); $ranks = mysql_fetch_array($result); // Because the only column in the select clause is "username" // $ranks will be an array with only one index, being "username" $ranks["userlevel"]; ?> Quote Link to comment https://forums.phpfreaks.com/topic/71719-arrays-help/#findComment-361205 Share on other sites More sharing options...
Jay2391 Posted October 3, 2007 Share Posted October 3, 2007 :-\ now i am confuse... I need the while statement because i am getting all the names and they all need to have a hyperlink attach to click to access their profile... i do not understand what you are saying can you make notes on my code??? Quote Link to comment https://forums.phpfreaks.com/topic/71719-arrays-help/#findComment-361213 Share on other sites More sharing options...
wildteen88 Posted October 3, 2007 Share Posted October 3, 2007 :-\ now i am confuse... I need the while statement because i am getting all the names and they all need to have a hyperlink attach to click to access their profile... i do not understand what you are saying can you make notes on my code??? You in the right thread? Quote Link to comment https://forums.phpfreaks.com/topic/71719-arrays-help/#findComment-361215 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.