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

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;

Archived

This topic is now archived and is closed to further replies.

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