I am stuck to the following problem.I am applying page logic to the website which is survey kind of data. I am unable to fetch the records in loop till the from_reference_id tends to null, And also there can be and/or condition between the two reference from_reference_id and to_reference_id and loop ends till to_reference_id tends to null.Also there can be and/or condition between the reference id which is being matched with the answer provided on the survey. The aggregate result will defined the page redirection. As for example from_reference_id is 1 and to to_reference is 2 then based on the question it will be solved as equation like this. So I just want to route page to be redirected.
if(q1:a1) is selected then goto page 3
or (q2:a1) is selected then goto page 3
where q1
represent question and a1
denotes answer1
Here is the database structure
https://i.stack.imgur.com/9CWHT.png
the code I have tried
$sql_select_query="SELECT * from `tbl_branching_logic` where `p_id`='$page_id' and `s_id`='$global_survey_id' and `r_id`='$r_id'";
$result=mysql_query($sql_select_query);
while($row=mysql_fetch_assoc($result))
{
if($row['to_reference_id']!=0 && $row['and_or']!='')
{
//condition
}
}
This is the html structure image enter image description here