Jump to content

arrays help


Simon180

Recommended Posts

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

Link to comment
Share on other sites

"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"];
?>

 

Link to comment
Share on other sites

:-\

 

 

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???

Link to comment
Share on other sites

:-\

 

 

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?

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.