Working on 2 different tables
Posted: Thu May 14, 2009 9:01 am
I have a website that interacts with a mysql database via php. The database has 3 tables. 'user', 'goals', 'steps'
For each record in user there may be many in goals and for each record in goals there may be many in steps.
On the website I have the user log in. They can decide then that they would like to set some goals. So they are directed to the goals form and their information is entered into the goals form and it is linked through their userid which is in both the goals table and the user table. userid is carried as a variable in a session when they log in. My challenge is after they submit the goals form they are then redirected to a steps form where they are supposed to fill out steps towards achieving the goal that they just submitted in the goal form. I need to link the steps to that specific goal (remember there may be many goals by each user and I need to link it to the one they just entered). I wasn't sure exactly what the best method to use would be.
The only thought that I had was to create a randomly generated number using php on the goals form and insert it into the goals table and then carry that variable over to the step form upon completing the goal form. That would then be the link between the step form and the goal form. If so exactly how would you create the random variable & how would you carry it over to the steps form?
For each record in user there may be many in goals and for each record in goals there may be many in steps.
On the website I have the user log in. They can decide then that they would like to set some goals. So they are directed to the goals form and their information is entered into the goals form and it is linked through their userid which is in both the goals table and the user table. userid is carried as a variable in a session when they log in. My challenge is after they submit the goals form they are then redirected to a steps form where they are supposed to fill out steps towards achieving the goal that they just submitted in the goal form. I need to link the steps to that specific goal (remember there may be many goals by each user and I need to link it to the one they just entered). I wasn't sure exactly what the best method to use would be.
The only thought that I had was to create a randomly generated number using php on the goals form and insert it into the goals table and then carry that variable over to the step form upon completing the goal form. That would then be the link between the step form and the goal form. If so exactly how would you create the random variable & how would you carry it over to the steps form?