I have a database with a cascading approach to its rows and I can either get the results repeated over and again or I cannot get the end portions of this to return to the page (e5). Here is the data:
Rolename, Class, e2, e3, e4 ,e5
Example
Rolename: Role 1
Class: 123
e5: five
Rolename: Role 1
Class: 123
e5: six
Rolename could be repeated many times with different e5 values.
In my code I have the following, and it is returning the results over and again, you will see that I am trying to push the results to a table. Right now it shows the rolename over and again. If I group the records in the query it only returns the first row. I need to show one Role, possibly more classes and likely more e2, e3 ,e4 ,e5., make sense?
$sql1=` $DB_con2->prepare("SELECT ability_id, oprid, rolename, class, e2, e3, e4, e5 FROM validation_abilities WHERE ability_id IN ('".$ability_role_implode."') AND rolename = :rolename");
$sql1->execute(array(":rolename"=>$rolename));
while($sql1_results1 = $sql1->fetch(PDO::FETCH_ASSOC)){
$ability_id_role = $sql1_results1['ability_id'];
$oprid_ul1 = $sql1_results1['oprid'];
$rolename1 = $sql1_results1['rolename'];
$classid1 = $sql1_results11['classid'];
$e2_1 = $sql1_results1['e2'];
$e3_1 = $sql1_results1['e3'];
$e4_1 = $sql1_results1['e4'];
$e5_1 = $sql1_results1['e5'];
echo "<td>";
if(!empty($classid1)){
echo $application_classid_title;
echo "<p class=\"v\"><a href=\"$environment/access/analysis_actions/e2/?app=$app&ru=U&classid=$classid1&ruleid=$rule_id_returned\"> $classid1</a></p><br/>";
}
if(!empty($e2_1)){
echo $application_e2_title;
echo "<p class=\"v\"><a href=\"$environment/access/analysis_actions/e2/?app=$app&ru=U&e2=$e2_1&ruleid=$rule_id_returned\">$e2_1</a></p><br/>";
}
if(!empty($e3_1)){
echo $application_e3_title;
echo "<p class=\"v\"><a href=\"$environment/access/analysis_actions/e3/?app=$app&ru=U&e3=$e3_1&ruleid=$rule_id_returned\"> $e3_1</a></p><br/>";
}
if(!empty($e4_1)){
echo $application_e4_title;
echo "<p class=\"v\"><a href=\"$environment/access/analysis_actions/e4/?app=$app&ru=U&e4=$e4_1&ruleid=$rule_id_returned\">$e4_1</a></p><br/>";
}
if(!empty($e5_1)){
echo $application_e5_title;
echo "<p class=\"v\"><a href=\"$environment/access/analysis_actions/e5/?app=$app&ru=U&e5=$e5_1&ruleid=$rule_id_returned\">$e5_1</a></p><br/>";
}
echo "</p>";
echo "</td>";
}
Please let me know if you need anything else, I have been going round and round in circles on this one..
Thanks,
DS