Davie33 Posted September 13, 2011 Share Posted September 13, 2011 i have a ranking code and i would like to know how i can add another $rquery. $ranking = array(); $rquery = yasDB_select("SELECT username FROM user ORDER BY plays"); // only way to rank I see is by plays which you can use to count comments/user submissions $i=0; while ($rank = $rquery->fetch_array(MYSQLI_ASSOC)) { $ranking[$i] = $rank['username']; $i++; } $rank = array_search($username,$ranking)+1; What i mean is this code here is giving a member a rank to how many games they have play. so say a member played 102 game and the other member played 94.Member one would be rank 1 and 2nd member is rank 2 how do i add another sql to it so it will do the same for this sql ? CREATE TABLE IF NOT EXISTS `topic` ( `id` int(11) NOT NULL AUTO_INCREMENT, `userid` int(11) NOT NULL DEFAULT '0', `ipaddress` varchar(255) NOT NULL DEFAULT '', `comment` text NOT NULL, `name` varchar(255) NOT NULL DEFAULT '', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; Link to comment https://forums.phpfreaks.com/topic/247090-query-2-sql-databases/ Share on other sites More sharing options...
fenway Posted September 13, 2011 Share Posted September 13, 2011 You're trying to assign rank in mysql? There are dozens of tutorials. You're just asking for a counter, right? Link to comment https://forums.phpfreaks.com/topic/247090-query-2-sql-databases/#findComment-1269023 Share on other sites More sharing options...
Davie33 Posted September 13, 2011 Author Share Posted September 13, 2011 You're just asking for a counter, right? yip just the counter. Link to comment https://forums.phpfreaks.com/topic/247090-query-2-sql-databases/#findComment-1269024 Share on other sites More sharing options...
fenway Posted September 14, 2011 Share Posted September 14, 2011 Then you might as well number them in PHP -- or, if you insist, use user variables in mysql. Link to comment https://forums.phpfreaks.com/topic/247090-query-2-sql-databases/#findComment-1269161 Share on other sites More sharing options...
Davie33 Posted September 16, 2011 Author Share Posted September 16, 2011 Hi can i pm u with the full code to what am trying to do ?. Link to comment https://forums.phpfreaks.com/topic/247090-query-2-sql-databases/#findComment-1269751 Share on other sites More sharing options...
fenway Posted September 16, 2011 Share Posted September 16, 2011 Hi can i pm u with the full code to what am trying to do ?. No, I don't provide "full code". There are countless examples on this forum of using user variables as counters. Link to comment https://forums.phpfreaks.com/topic/247090-query-2-sql-databases/#findComment-1270100 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.