Jump to content

Nik Top

New Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Nik Top's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I see thank you thank you. problem SOLVED !!! :D :D
  2. Oh wait there is new issue coming up. i change my table post to 0=Noob 50=Member 150 = Metal 1200 = Silver 70000 = Gold function is doing good because I add " = " into the code " if ($userRank >= $k) { " mysql is being stupid if I put 1600 = Metal but 1260 = silver but still a big issue now I want to focus on function but i tried and having difficulty puting mysql in it. please help
  3. Thank you Thank you both of them work but function not working right if i put 50 post for function = member, if i put 100 = metal, if i put 101=silver Not a big issue i know where it came from so i can fix it. anyway the mysql works great!!! I found out why i making it wrong because I did not put the " DESC " in the query. Here is my Table: ( I change table name to rank_sys because "WebStyles" advice CREATE TABLE rank_sys ( id int NOT NULL auto_increment, post varchar( 30 ) NOT NULL, rank varchar( 50 ) NOT NULL, PRIMARY KEY (id) ); INSERT INTO rank_sys (post, rank) VALUES ('0','Noob'); INSERT INTO rank_sys (post, rank) VALUES ('10','Member'); INSERT INTO rank_sys (post, rank) VALUES ('50','Metal'); INSERT INTO rank_sys (post, rank) VALUES ('100','Silver'); INSERT INTO rank_sys (post, rank) VALUES ('200','Gold'); ---------------------------------- rank.php $user_post="120"; echo "User = $user_post Posts<br><br>"; // ---- function error not fix yet function userRank($userRank) { $rank=array(0=>'Noob',10=>'Member',50=>'Metal',100=>'Silver',200=>'Gold'); foreach($rank as $k=>$v) { if ($userRank > $k) { $ranking=$v; }else { break; } } return $ranking; } // ------- function rank echo "User Rank: ".userRank($user_post); echo "<br><br>"; $query_rank=mysql_query("SELECT post,rank FROM rank_sys WHERE post<='$user_post' ORDER BY post DESC LIMIT 1") or die ("Error"); while ($row=mysql_fetch_array($query_rank)){ $rank=$row['rank']; } // -------- MySQL rank echo "User Rank: $rank"; Great Great Thanks
  4. thank you for the reply I dont know how to use the WebStyles method. for the mysql table i try the order by in many different ways but seems not working at all. I see that on this site there is a user post = rank system. thats what I wanted I don't think just using mysql table will solve this. Is there a different solution such as using a function or something else?
  5. Thank you for you reply, and the advice but it seems not working. it gave me this: user 120 = rank: Noob I guess I am going the wrong direction, Is there a function for this? and how to start? Please help
  6. Thank you for your reply but thats not the answer I want this is what I want if user_post = 120 then rank = Silver but some how I am having trouble making it to the right rank. anyway thank you for the help. please if anyone got a better solution for this?
  7. I am having trouble on user post = rank This is the rank table: ----------------- post | rank ----------------- 0 | Noob 10 | Member 50 | Metal 100 | Silver 200 | Gold $user_post="120"; $query_rank=mysql_query("SELECT * FROM rank WHERE post<='$user_post' OR post>='$user_post'") or die ("Error"); while ($row=mysql_fetch_assoc($query_rank)){ $rank=$row['rank']; } echo "User Rank: $rank"; The above code output: User Rank: Gold The right output should be: User Rank: Silver Please help It will be better if someone willing to share a better ranking code.
  8. hi i am having trouble putting a variable in strtotime() $num = "5"; $future=date("Y-m-d", strtotime('+$num day')); please help is there a way to put in a variable
×
×
  • 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.