/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Quiz type of game – random questions for users

Hi

I’m working on quiz type of game where a user can invite another user to play the game – I have 10 questions that are picked randomly for each game session from a database. What I need to do is generate a link that has the same questions for both users.
As far I thought of creating table with session id, both usernames, an array (questions and possible answers), and two fields for answers sets for comparison.
I know storing an array in one field is not a good practice however I need to pass it to my JavaScript code for both users and they need to be the same – so I cannot fetch the same questions for those users using the same query. I would use serialize() and unserialize() functions to achieve that.
I’m wondering if there might be a more efficient way of handling this.

Thanks a lot for any advice.

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@Strider64Jun 11.2015 — I personally see nothing wrong in using serialize() and unserialize() to keep track of the questions asked, I'm sure there are other clever methods out there. However, this is just a trivia game and if it gets the job done in a relatively quick time (it should it's only 10 questions) then why not?
×

Success!

Help @Tyska spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...