czukoman20 Posted December 2, 2007 Share Posted December 2, 2007 I have an issue with what i am trying to do for my site. I am not sure where to start to do this. The setup i have already is i have an ID number to every user. The ID number is then used to get all of the info that i want to see on that user. I would like to be able to display this information on 1 page with 5 per page. The only issue is. Say i have 400 users on my site all that want to display information. I would like it so nobody gets a better deal over someone else. So i figured it should be randomized. so 5 out of 400 users per page. But then i thought.. well now i dont want the same user popping up more than once before the whole entire 400 users have been looked at. Is there any possible way to display 5 users randomly per page, but not have any random user repeats. Thanks .. if this isnt clear please tell me so i can make a diagram. Quote Link to comment https://forums.phpfreaks.com/topic/79783-solved-number-counter/ Share on other sites More sharing options...
kratsg Posted December 2, 2007 Share Posted December 2, 2007 The best way that I can think up, is to randomize all the users, save this to a unique text file (which is tracked by sessions), and read from the text file to get the next set of users, etc... Quote Link to comment https://forums.phpfreaks.com/topic/79783-solved-number-counter/#findComment-404031 Share on other sites More sharing options...
czukoman20 Posted December 2, 2007 Author Share Posted December 2, 2007 Can u elaborate on that a little bit. i quite dont understand sorry Quote Link to comment https://forums.phpfreaks.com/topic/79783-solved-number-counter/#findComment-404032 Share on other sites More sharing options...
sasa Posted December 2, 2007 Share Posted December 2, 2007 try <?php session_start(); $IDs = range(1,10);// your ID array $randID = array(); $per_page = 3; if (isset($_SESSION['rID'])) $randID = $_SESSION['rID']; if (count($randID) < $per_page){ shuffle($IDs); $randID = array_merge($randID,$IDs); $randID = array_values(array_unique($randID)); } $curIDs = array(); for ($i = 0; $i < $per_page; $i++){ $curIDs[] = $randID[$i]; unset($randID[$i]); } $_SESSION['rID'] = array_values($randID); foreach ($curIDs as $v) echo $v, "<br />\n"; ?> <a href="">Next</a> Quote Link to comment https://forums.phpfreaks.com/topic/79783-solved-number-counter/#findComment-404082 Share on other sites More sharing options...
HaLo2FrEeEk Posted December 2, 2007 Share Posted December 2, 2007 I don't think people are going to freak out that they aren't first in the list if the list is alphabetized, it isn't YOU that's putting the A people first, it's the system. Quote Link to comment https://forums.phpfreaks.com/topic/79783-solved-number-counter/#findComment-404085 Share on other sites More sharing options...
monkeybidz Posted December 2, 2007 Share Posted December 2, 2007 Do you have the $query that calls these id's so that we can see what you are working with? Quote Link to comment https://forums.phpfreaks.com/topic/79783-solved-number-counter/#findComment-404086 Share on other sites More sharing options...
Stooney Posted December 2, 2007 Share Posted December 2, 2007 You could store all of the user info in an array then shuffle it with shuffle() http://us2.php.net/shuffle Quote Link to comment https://forums.phpfreaks.com/topic/79783-solved-number-counter/#findComment-404106 Share on other sites More sharing options...
czukoman20 Posted December 2, 2007 Author Share Posted December 2, 2007 I just browsed through the code this mornin. I cant do anything yet.. so i will try it later and give u guys more feedback. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/79783-solved-number-counter/#findComment-404279 Share on other sites More sharing options...
czukoman20 Posted December 3, 2007 Author Share Posted December 3, 2007 Well this stuff seems a bit over my level of knowledge.. but i did have another thought Would it be possible to use the random number function and then have a range from 1-400 then for the next number have it range from 1- 400 but exclude the 1st number? Quote Link to comment https://forums.phpfreaks.com/topic/79783-solved-number-counter/#findComment-405582 Share on other sites More sharing options...
czukoman20 Posted December 4, 2007 Author Share Posted December 4, 2007 Anyone have any opinion in that simply yes or no answer type deal. Quote Link to comment https://forums.phpfreaks.com/topic/79783-solved-number-counter/#findComment-405597 Share on other sites More sharing options...
teng84 Posted December 4, 2007 Share Posted December 4, 2007 yes! Quote Link to comment https://forums.phpfreaks.com/topic/79783-solved-number-counter/#findComment-405599 Share on other sites More sharing options...
czukoman20 Posted December 4, 2007 Author Share Posted December 4, 2007 Thanks u dont have to a jerk about it. Quote Link to comment https://forums.phpfreaks.com/topic/79783-solved-number-counter/#findComment-405605 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.