puyunk Posted May 28, 2013 Author Share Posted May 28, 2013 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.. Quote Link to comment https://forums.phpfreaks.com/topic/277915-generate-non-repetition-datas-from-database/page/2/#findComment-1432757 Share on other sites More sharing options...
mac_gyver Posted May 29, 2013 Share Posted May 29, 2013 the undefined index error is because you need to - if $_SESSION['used'] is an array of the id's of the questions that have been output (initialize to an empty array if it doesn't exist) Quote Link to comment https://forums.phpfreaks.com/topic/277915-generate-non-repetition-datas-from-database/page/2/#findComment-1432874 Share on other sites More sharing options...
puyunk Posted May 29, 2013 Author Share Posted May 29, 2013 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.. Did not have any vision in how to do that.. Quote Link to comment https://forums.phpfreaks.com/topic/277915-generate-non-repetition-datas-from-database/page/2/#findComment-1432876 Share on other sites More sharing options...
mac_gyver Posted May 29, 2013 Share Posted May 29, 2013 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; Quote Link to comment https://forums.phpfreaks.com/topic/277915-generate-non-repetition-datas-from-database/page/2/#findComment-1432928 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.