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
https://forums.phpfreaks.com/topic/71719-arrays-help/
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
https://forums.phpfreaks.com/topic/71719-arrays-help/#findComment-361205
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
https://forums.phpfreaks.com/topic/71719-arrays-help/#findComment-361215
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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