Jump to content

Generate non-repetition datas from database


puyunk

Recommended Posts

Sorry to keep bothering, but this code

$ids = implode(',',$_SESSION['used']);

keep giving me errors..

 

and since I am really new in PHP code, I am really unfamiliar with your second line also..

$not_in = empty($ids) ? '' : " AND SoalID NOT IN($ids)";

the error that I get is like this..

 

undefined index in line 17 <-- which is the first line of the updated code..

I changed my query into yours, and add the first and second line of the code right on top of it..

 

Need more information about this..

Thanks before hand..

Link to comment
Share on other sites

I am more confused now..

 

Can you show me the code in how to do that?

How to put the ID of the question that are already used in an array, and connect them using session..  :confused:

 

Did not have any vision in how to do that..

Link to comment
Share on other sites

you do realize that if you don't understand the basics of what you are trying to do or the direction given in the replies that you should probably just hire someone to code this for you? the 'jargon' used in any activity isn't to exclude people, it's to shorten the amount of time it takes to communicate an idea, so that someone doesn't have to write a book each time to cover the basics, which is why there are books, tutorials, and classes to learn the basics from.

 

 

initializing a (session) variable to a specific state if it doesn't exist -

session_start();

// initialize to an empty array if it doesn't exist
if(!isset($_SESSION['used'])){
    $_SESSION['used'] = array();
}

since you need to reference the SoalID at the time you echo the random question, you either need to explode the data string and get the first value or you can use the SoalID as the index for your $arr array when you retrieve the data from the query.

 

assuming you can get the id value for the question you are echoing, storing it to the $_SESSION['used'] array -

$_SESSION['used'][] = $SoalID;
Link to comment
Share on other sites

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.