Have struggled to come up with a solution so would be thankful if you could give me a helping hand!
Want to dynamically create one array based on information in my sql db.
Don’t think I’m far from the goal…..
Mysql setup:
Table tblexemptiontype (fields id, exemptiontype)
Table tblcontroltype (typeid, controlname)
Example rows in tblexemptiontype,
Id exemptiontype
67 ACCESS CONTROL
64 AUDIT AND ACCOUNTABILITY
Example rows in tblcontroltype,
67 AC1
67 AC2
64 AA1
64 AA2
Etc.etc……
Tblexemptiontype. Id= tblcontroltype. Typeid is where the two tables are ‘linked’
PHP code:
$sql = “SELECT id FROM tblexemptiontype ORDER BY exemptiontype”;
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)){
$control[$row[0]] = array();
$sql2 = “SELECT typeid, controlname FROM tblcontrolname WHERE typeid = $row[0] ORDER BY controlname”;
$rs1 = mysql_query($sql2);
while($rows1 = mysql_fetch_array($rs1)) {
$str = $str.”‘”.$rows1[0].”‘,”.$rows1[1].”‘,”;
$control[$row[0]] = ($str);
}
$str = “”;
}
If I echo $control[67][1]; then I should get ‘AC1’ and $control[64][3]; should give me ’AA2’ etc.etc….
With this code as I have added a string to $control I only get one character.
My guess is that something in this section should be different,
$str = $str.”‘”.$rows1[0].”‘,”.$rows1[1].”‘,”;
$control[$row[0]] = ($str);
}
$str = “”;
Please help!!!!
?