akaballa123
Technical User
Hi,
I am trying to create this scenario where I can create a table that display all the trainings that each particular organization provides.
I have two mysql tables related to this. I fetched the organization names from the orgtbl and the training names from addtrainingtbl .
I want something outputting in excel essential something like this:
Organization Name Training Name
Org A T1
T2
Org B T3
T4
T5
etc.
I am displaying the organization names, but I am not able to retrieve the training names corresponding to the organizations. Following is my code:
Plz Help!
Thanks!
I am trying to create this scenario where I can create a table that display all the trainings that each particular organization provides.
I have two mysql tables related to this. I fetched the organization names from the orgtbl and the training names from addtrainingtbl .
I want something outputting in excel essential something like this:
Organization Name Training Name
Org A T1
T2
Org B T3
T4
T5
etc.
I am displaying the organization names, but I am not able to retrieve the training names corresponding to the organizations. Following is my code:
Code:
else if ($_REQUEST['trainingOrg'])
{
$orgT = @mysql_query('SELECT orgName FROM orgtbl');
$filepnt3 = fopen("organizationalTrainingReport.xls", 'w+');
$content3 = '<table cellpadding="10" border="1" width="30%">' ;
$content3 .= ' <tr><td bgcolor = "blue" align="center"><b>' . 'Organization Name' . '</b></td>' . '<td bgcolor = "blue" align="center"><b>' . 'Training Name' . '</b></td> </tr>' ;
while ($row = mysql_fetch_array($orgT))
{
$orgName = $row['orgName'];
$content3 .= '<tr><td align="center">' . $orgName . '</td>' ;
$trainingOrg = @mysql_query('SELECT trainingName FROM addtrainingtbl WHERE organization = \'$orgName\'');
while($trn = mysql_fetch_array($trainingOrg))
{
$content3 .='<td align="center">' . $trn['trainingName'] . '</td></tr>';
}
}
$content3 .= '</table>';
fwrite($filepnt3, $content3);
fclose($filepnt3);
echo '<a href="organizationalTrainingReport.xls">Click here to download as Excel File</a>';
echo '<br><br><a href ="genReport.php">Click here to go back to Generate Report</a>';
}
Plz Help!
Thanks!