Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Server Development
Habbo Retros
Habbo Q&A
How to convert users id to username
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="JayC" data-source="post: 426090" data-attributes="member: 36373"><p>Try This</p><p>[SPOILER="Community.php"]</p><p><?php</p><p>$eo = 'even';</p><p></p><p>function GenerateRoomOccupancy($usersNow, $usersMax)</p><p>{</p><p>$num = 1;</p><p>$percentage = intval(($usersNow / $usersMax) * 100);</p><p></p><p>if ($percentage <= 0)</p><p>{</p><p>$num = 1;</p><p>}</p><p>else if ($percentage < 35)</p><p>{</p><p>$num = 2;</p><p>}</p><p>else if ($percentage < 75)</p><p>{</p><p>$num = 3;</p><p>}</p><p>else if ($percentage < 100)</p><p>{</p><p>$num = 4;</p><p>}</p><p>else if ($percentage >= 100)</p><p>{</p><p>$num = 5;</p><p>}</p><p></p><p>return 'room-occupancy-' . $num;</p><p>}</p><p></p><p>function userIdToUsername($userId){</p><p> $getUserName = mysql_query("SELECT `username` FROM `user` WHERE `id` = '".$userId."' LIMIT 1");</p><p> </p><p> if(mysql_num_rows($getUserName) == 1){</p><p> $usersName = mysql_fetch_assoc($getUserName);</p><p> return $usersName['username'];</p><p> }else{</p><p> return $userId;</p><p> }</p><p> </p><p>}</p><p>?></p><p><div class="habblet-container "></p><p><div class="cbb clearfix settings "></p><p></p><p><h2 class="title">Hot Rooms</h2></p><p></p><p><style type="text/css"></p><p>.room-occupancy-1 { background-image: url('{url}/app/tpl/skins/Habbo/images/rooms/room_icon_1.gif') !important; }</p><p>.room-occupancy-2 { background-image: url('{url}/app/tpl/skins/Habbo/images/rooms/room_icon_2.gif') !important; }</p><p>.room-occupancy-3 { background-image: url('{url}/app/tpl/skins/Habbo/images/rooms/room_icon_3.gif') !important; }</p><p>.room-occupancy-4 { background-image: url('{url}/app/tpl/skins/Habbo/images/rooms/room_icon_4.gif') !important; }</p><p>.room-occupancy-5 { background-image: url('{url}/app/tpl/skins/Habbo/images/rooms/room_icon_5.gif') !important; }</p><p></style></p><p></p><p><div id="rooms-habblet-list-container-h124" class="recommendedrooms-lite-habblet-list-container"></p><p><ul class="habblet-list"></p><p></p><p><?php</p><p></p><p>$get = mysql_query("SELECT * FROM rooms WHERE roomtype = 'private' ORDER BY users_now DESC LIMIT 5")or die(mysql_error());</p><p></p><p>while ($room = mysql_fetch_assoc($get))</p><p>{</p><p>if ($eo == 'even')</p><p>{</p><p>$eo = 'odd';</p><p>}</p><p>else</p><p>{</p><p>$eo = 'even';</p><p>}</p><p></p><p>echo '<li class="' . $eo . '"></p><p><span class="clearfix enter-room-link ' . GenerateRoomOccupancy($room['users_now'], $room['users_max']) . '" title="Go There" roomid="' . $room['id'] . '"></p><p><span class="room-enter">Enter room</span></p><p><span class="room-name">' . ($room['caption']) . '</span></p><p><span class="room-description">' . ($room['description']) . '</span> </p><p><span class="room-owner">Owner: <a href="/home/' . ($room['owner']) . '">' . ($room['owner']) . '</a></span></p><p></span></p><p></li>';</p><p>}</p><p></p><p>?></p><p></p><p><div id="room-more-data-h124" style="display: none"></p><p><ul class="habblet-list room-more-data"></p><p></p><p><?php</p><p></p><p>$get = mysql_query("SELECT * FROM rooms WHERE roomtype = 'private' ORDER BY users_now DESC LIMIT 6,10")or die(mysql_error());</p><p></p><p>while ($room = mysql_fetch_assoc($get))</p><p>{</p><p>if ($eo == 'even')</p><p>{</p><p>$eo = 'odd';</p><p>}</p><p>else</p><p>{</p><p>$eo = 'even';</p><p>}</p><p></p><p>echo '<li class="' . $eo . '"></p><p><span class="clearfix enter-room-link ' . GenerateRoomOccupancy($room['users_now'], $room['users_max']) . '" title="Go There" roomid="' . $room['id'] . '"></p><p><span class="room-enter">Enter room</span> <br></p><p><span class="room-name">' . ($room['caption']) . '</span> <br></p><p><span class="room-description">' . ($room['description']) . '</span> </p><p><span class="room-owner">Owner: <a href="/home/' . ($room['owner']) . '">' . userIdToUsername($room['owner']) . '</a></span></p><p></span></p><p></li>';</p><p>}</p><p></p><p>?></p><p></p><p></ul></p><p></div></p><p></p><p><div class="clearfix"></p><p><a href="#" class="room-toggle-more-data" id="room-toggle-more-data-h124">More Rooms!</a></p><p></div></p><p></p><p></div></p><p></p><p><script type="text/javascript"></p><p>L10N.put("show.more", "Show more rooms");</p><p>L10N.put("show.less", "Show less rooms");</p><p>var roomListHabblet_h124 = new RoomListHabblet("rooms-habblet-list-container-h124", "room-toggle-more-data-h124", "room-more-data-h124");</p><p></script></p><p></p><p></div></p><p></div></p><p>[/SPOILER]</p></blockquote><p></p>
[QUOTE="JayC, post: 426090, member: 36373"] Try This [SPOILER="Community.php"] <?php $eo = 'even'; function GenerateRoomOccupancy($usersNow, $usersMax) { $num = 1; $percentage = intval(($usersNow / $usersMax) * 100); if ($percentage <= 0) { $num = 1; } else if ($percentage < 35) { $num = 2; } else if ($percentage < 75) { $num = 3; } else if ($percentage < 100) { $num = 4; } else if ($percentage >= 100) { $num = 5; } return 'room-occupancy-' . $num; } function userIdToUsername($userId){ $getUserName = mysql_query("SELECT `username` FROM `user` WHERE `id` = '".$userId."' LIMIT 1"); if(mysql_num_rows($getUserName) == 1){ $usersName = mysql_fetch_assoc($getUserName); return $usersName['username']; }else{ return $userId; } } ?> <div class="habblet-container "> <div class="cbb clearfix settings "> <h2 class="title">Hot Rooms</h2> <style type="text/css"> .room-occupancy-1 { background-image: url('{url}/app/tpl/skins/Habbo/images/rooms/room_icon_1.gif') !important; } .room-occupancy-2 { background-image: url('{url}/app/tpl/skins/Habbo/images/rooms/room_icon_2.gif') !important; } .room-occupancy-3 { background-image: url('{url}/app/tpl/skins/Habbo/images/rooms/room_icon_3.gif') !important; } .room-occupancy-4 { background-image: url('{url}/app/tpl/skins/Habbo/images/rooms/room_icon_4.gif') !important; } .room-occupancy-5 { background-image: url('{url}/app/tpl/skins/Habbo/images/rooms/room_icon_5.gif') !important; } </style> <div id="rooms-habblet-list-container-h124" class="recommendedrooms-lite-habblet-list-container"> <ul class="habblet-list"> <?php $get = mysql_query("SELECT * FROM rooms WHERE roomtype = 'private' ORDER BY users_now DESC LIMIT 5")or die(mysql_error()); while ($room = mysql_fetch_assoc($get)) { if ($eo == 'even') { $eo = 'odd'; } else { $eo = 'even'; } echo '<li class="' . $eo . '"> <span class="clearfix enter-room-link ' . GenerateRoomOccupancy($room['users_now'], $room['users_max']) . '" title="Go There" roomid="' . $room['id'] . '"> <span class="room-enter">Enter room</span> <span class="room-name">' . ($room['caption']) . '</span> <span class="room-description">' . ($room['description']) . '</span> <span class="room-owner">Owner: <a href="/home/' . ($room['owner']) . '">' . ($room['owner']) . '</a></span> </span> </li>'; } ?> <div id="room-more-data-h124" style="display: none"> <ul class="habblet-list room-more-data"> <?php $get = mysql_query("SELECT * FROM rooms WHERE roomtype = 'private' ORDER BY users_now DESC LIMIT 6,10")or die(mysql_error()); while ($room = mysql_fetch_assoc($get)) { if ($eo == 'even') { $eo = 'odd'; } else { $eo = 'even'; } echo '<li class="' . $eo . '"> <span class="clearfix enter-room-link ' . GenerateRoomOccupancy($room['users_now'], $room['users_max']) . '" title="Go There" roomid="' . $room['id'] . '"> <span class="room-enter">Enter room</span> <br> <span class="room-name">' . ($room['caption']) . '</span> <br> <span class="room-description">' . ($room['description']) . '</span> <span class="room-owner">Owner: <a href="/home/' . ($room['owner']) . '">' . userIdToUsername($room['owner']) . '</a></span> </span> </li>'; } ?> </ul> </div> <div class="clearfix"> <a href="#" class="room-toggle-more-data" id="room-toggle-more-data-h124">More Rooms!</a> </div> </div> <script type="text/javascript"> L10N.put("show.more", "Show more rooms"); L10N.put("show.less", "Show less rooms"); var roomListHabblet_h124 = new RoomListHabblet("rooms-habblet-list-container-h124", "room-toggle-more-data-h124", "room-more-data-h124"); </script> </div> </div> [/SPOILER] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Server Development
Habbo Retros
Habbo Q&A
How to convert users id to username
Top