ZulfadlyAshBurn Posted September 11, 2020 Share Posted September 11, 2020 (edited) I'm trying to create an application where the admin is able to add mutiple goals. For example, - Goal 1 - Goal 2 - Goal 3 Once the goals have been set, he then can generate a task for users to follow the goals for a specific users. For example USER A Goal 3, Goal 2, Goal 1 USER B Goal 2, Goal 1, Goal 3 USER C Goal 1, Goal 2, Goal 3 The user have to follow the goal as set and can only proceed to the next goal one the previous one has been completed. The goals will defer everyday. Anyone can guide me to the right direction? Edited September 11, 2020 by ZulfadlyAshBurn Grammer Quote Link to comment https://forums.phpfreaks.com/topic/311472-step-by-step/ Share on other sites More sharing options...
requinix Posted September 11, 2020 Share Posted September 11, 2020 The right direction for what, exactly? Databases? Application design? User experience? You have an idea for something but we're going to need more than just that. Quote Link to comment https://forums.phpfreaks.com/topic/311472-step-by-step/#findComment-1581317 Share on other sites More sharing options...
ZulfadlyAshBurn Posted September 12, 2020 Author Share Posted September 12, 2020 I'm looking a application design. I may have something that I can work with however I'm having issue with the $_SESSION. dummy.php (To Create dummy array and store into session) <?php session_start(); $route = array(); $visited = array(); $wordlist = "goal1,goal2,goal3"; $route = array_merge($route, array_map('trim', explode(",", $wordlist))); $_SESSION['route'] = $route; $_SESSION['visited'] = $visited; ?> destroy.php (Remove all session in page to re-create new array using dummy.php) <?php session_start(); print_r($_SESSION['route']); session_destroy(); print_r($_SESSION['route']); ?> run.php (using get method eg. "run.php?id=goal1") <?php session_start(); // route is arary pulled from DB (dummy.php) $route = $_SESSION['route']; print_r($route); // visited is an array in store in session $visited = $_SESSION['visited']; print_r($visited); // result to compare the array in db and session $result=array_diff($route,$visited); print_r($result); if(isset($_GET['id'])) { if (current($result) == $_GET['id']) { array_push($visited, $_GET['id']); echo "Visited" . $_GET['id']; // update session $_SESSION['visited'] = $visited; } else { echo "Visit in order"; } } ?> The issue I'm facing currently is then when the page runs, the data(id) is stored in to the $_SESSION['visited'] before the whole page runs from the top. Quote Link to comment https://forums.phpfreaks.com/topic/311472-step-by-step/#findComment-1581323 Share on other sites More sharing options...
Barand Posted September 12, 2020 Share Posted September 12, 2020 Your fist post talked about users, goals and tasks. Your second is all about visits and routes. Have you moved on to another problem somewhere inbetween and haven't told us? Quote Link to comment https://forums.phpfreaks.com/topic/311472-step-by-step/#findComment-1581324 Share on other sites More sharing options...
ZulfadlyAshBurn Posted September 12, 2020 Author Share Posted September 12, 2020 Those are just variable names. I found a way to store the goals and task in the db and to call them back as an array which is separated by ",". The issue I'm facing is that when the page is loaded and the goal is marked as completed, the goal is added into the array before the page loads completely. Quote Link to comment https://forums.phpfreaks.com/topic/311472-step-by-step/#findComment-1581325 Share on other sites More sharing options...
Barand Posted September 12, 2020 Share Posted September 12, 2020 35 minutes ago, ZulfadlyAshBurn said: Those are just variable names. The point is, they are crap bad variable names if you want anyone else to understand how to relate your code to the problem you so poorly described. If you are storing the data as a comma separated lists, you need to normalize your data. Good luck; Quote Link to comment https://forums.phpfreaks.com/topic/311472-step-by-step/#findComment-1581326 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.