I have a table like this in my database.
| id | yes_answer | no_answer |
| a01 | a05 | a04 |
| a03 | a16 | a32 |
| a04 | c01 | a05 |
| a05 | a06 | c06 |
| a06 | a08 | a09 |
| a08 | c03 | a09 |
| a09 | a03 | |
| a16 | a33 | a02 |
| a32 | c04 | a16 |
| a33 | c05 | |
As An Explanation :
1.id
column represent an id of question. it is linked to another table on my database.
2.yes_answer
column represent the next question (like a01
) or conclusion (like c04
) you get when you answer the question represented by id
column with yes
or TRUE
or 1
value.
3.no_answer
is generally the same as yes_answer column
except that you get it when you answer question represented by id
column with no
, FALSE
, 0
value.
4. Every id
, yes_answer
, no_answer
is connected each other. The Result is A Pattern. When you Want to find a path that lead to answer c01
it will be like c05
-> a33
,a16
,a32
,a03
,a09
,a06
,a05
,a01
.
And Here I am Trying To Bactrack The Pattern From answer
column that marked with c
like c01
or c02
like above. And I've been able to bactrack only the beginning value of it Like (c05
-> a33
) and the rest is blank.
Here is My Code
$sqlQueryYes="SELECT * FROM tbl_path_inference WHERE yes_answer='c05'";
$execQueryYes=mysql_query($sqlQueryYes);<br />
$queryStatus=mysql_num_rows($execQueyYes); //Getting Query Status<br />
if($queryStatus == 1) {
$getDataYes=mysql_fetch_array($execQueryYes);
$ansPath=$ansPath." ".$getDataYes['id'];
} else { // if cant find answer on column yes_answer try on no_answer
$sqlQueryNo="SELECT * FROM tbl_path_inference WHERE no_answer='c05'";
$execQueryNo=mysql_query($sqlQueryNo);
$getDataNo=mysql_fetch_array($execQueryNo);
$ansPath=$ansPath." ".$getDataNo;
}
Anyone Have Solution On It. Im Still working It Now.