Jump to content

Recommended Posts

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 by ZulfadlyAshBurn
Grammer
Link to comment
https://forums.phpfreaks.com/topic/311472-step-by-step/
Share on other sites

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. 

Link to comment
https://forums.phpfreaks.com/topic/311472-step-by-step/#findComment-1581323
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/311472-step-by-step/#findComment-1581325
Share on other sites

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;

Link to comment
https://forums.phpfreaks.com/topic/311472-step-by-step/#findComment-1581326
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.