Jump to content

Recommended Posts

Ok I am creating an application that will display a group of random user_codes. The user veiwing them will check them off and hit a button that will repeat the process. My problem lies in the memory of those checked boxes. Once they are checked they should never be displayed again. I can't think of an easy way to do this without a huge server load. Only thing I can think of is a table for each user containing a line for each other user and keeping track like that. But that would create massive databases if I had say 10000 users with 9999 lines in each of thier tables. I hope there is a better way to do it. Thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/151948-user-history-with-php-and-mysql/
Share on other sites

but wouldnt that require a complete list to begin with? say i did it that way and 20 more users joined.. im really want to shy away from a 10000 line user table for each user.. im thinking of using ajax to load the app.. dont know if that changes anything..

Well, say you have an array like this:

 

$_SESSION['stuff'] = array(
'foo' => 'bar',
'hello' => 'hi',
'somebody' => 'me',
);

 

You can then generate your checkboxes using the key-value pair, i.e.

 

foreach ($_SESSION['stuff'] as $key => $value) {
echo "<input type='checkbox' name='stuffRemove[]' value='{$key}' id='stuff_{$key}'> <label for='stuff_{$key}'>{$value}</label>";
}

 

When the form has been submitted you'll have $_POST['stuffRemove'] which you can use to delete elements from the $_SESSION['stuff'] array:

 

foreach ($_POST['stuffRemove'] as $index) {
if (isset($_SESSION['stuff'][$index])) {
	unset($_SESSION['stuff'][$index]);
}
}

 

Repeat as many times as you need.

So if I got what you said correctly then the array would be my random group of users. The session would be basically a list of all the ones checked off and on the back end I would only need to store the session variable in a table with the current users id. Then when they log back in recall the session variable and have it query for 10 that aren't in the $session. Does that sound close?

 

Its for a game basically.. Each user in the game gets an id number xxx-xxx-xxx.. You then add friends by thier id. I want the users to be able to register with thier id on my site.. then get a list of other registered users which they can check off as they add them in game. And as there could be 25000 + users as the game has closer to 100k users each user could add them all with no duplicates.. once they have all been checked off the user would only see newly registered users which would then be checked off. Does that make since? As there could potentially be a lot of users and a lot of codes for each user to view/check I need it to remember them not just in session but permanently. And with that many users i would need a simpler way to log the ones done rather than a table for each user containing all the other users.. that would just get exponentially to big at some point. Thanks again for your help

Yes basically. In the game you can use (Your Level x 10) members that you've added to your friends list when fighting. So a level 100 would be able to use up to 1000 friends to fight with. There is no level cap that I've seen so a player at lvl 1000 would need 10k friends to fight at his best. So yes each person could add as many as possible. This is basically a networking site for players of that game. The more the better. Except on my end LOL. The more the more resources needed for each cycle which is what I need to reduce.

Right, okay. No offense, but that's a pretty stupid design. Nobody is going to wade through a list containing hundreds or thousands of users. It's simply to cumbersome. You might want to check up on HCI. It'll also result in poor performance. Your list of combinations will be growing exponentially, and with a sizable user base this will quickly become a bottleneck.

 

Why not simply allow users to add a username as friend (and return an error if they don't meet the friend requirements). Assuming you're able to view other users' profiles, you could add a "Add as friend" link if the formal requirements are met. Again, check the requirements when the link is clicked.

Although it's hard to believe people will sit there and do it haha. The point of the site isn't actually a social network. More of a tool to drive your group size in the game. There are several sites that allow people to list their friend code but they don't allow the person veiwing them to differentiate the ones they have done from the ones they haven't. If this isn't feasable then I can accept that. I was trying to make my site stand out from the rest.   

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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