Web Troubleshooter

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hills86
Forum Newbie
Posts: 2
Joined: Mon Jan 28, 2008 2:50 pm

Web Troubleshooter

Post by hills86 »

Hi all,

Ok this is sort of hard to explain so bare with me. Im trying to develop a website troubleshooter similar to the ms next next solution kind of thing.

i have a mysql db with a table structured as follows

ID, Question, Ans1, Ans2, Ans3, Link1, Link2, Link3, IsSolution
1 , HowOld,0-10,11-100,101-1000,2,3,4,0
2,.....

the link fields contain an ID for the next question... i.e. if they selected Ans2 then Link2 would be used to display the next question!

Ok, so now i've explained what im doing (i hope) here is the problem....

Im trying to write an add function. This is purely to stop people messing with the db and have some validation happen before it gets updated.

I can seem to create a way of checking that each question that has an answer has a reply.. each question can have no more that five replys... but there can be infinit amount of questions.

I hope this makes sense and someone can help.

Thanks in advance,

Rob.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Web Troubleshooter

Post by Christopher »

It would probably be better to do this with two tables:

Table 'questions':
ID, Question
1 , How old are you?
2,.....

Table 'answers':
ID, QuestionID, Ans, Link, IsSolution
1 , 1, 0-10, 2, 0
2 , 1, 11-100, 3, 0
3 , 1 ,101-1000, 4, 1
4,.....

That should also make it easier to manage and allow any number of possible answers
(#10850)
hills86
Forum Newbie
Posts: 2
Joined: Mon Jan 28, 2008 2:50 pm

Re: Web Troubleshooter

Post by hills86 »

I dont believe the table structure is going to be an issue. Im just trying to figure out some logic that will allow me to add a solution to the db going through every possible solution.

example:-

|_ Question1 _ Ans1 - Question1aa
|_ Ans1 - Question1a |_ Ans2 - [Solution]

Am i making sense! :|
Post Reply