Ok, so i am working on some software where users can submit tickets for bugs found on a website. I am using multiple checkboxes so users can check all browsers that are affected by the bug. The bug bugId
, title
, type
, etc are stored in one table called bugs
and the affected browsers are stored in another table called affectedbrowsers
. The commonality between the two tables is the bugId
. I have the form submitting everything correctly.
My problem is returning the data. I have an html table that has one row for each bug in the bugs
database table. There is one column called "Affected Browsers" that i would like to populate with the data from the affectedbrowsers
table. I tried using a while loop to loop through the bugs and echo out the rows in the html table and using a second while loop within that first while loop that would query the affectedbrowsers
table and find all the records that have the same bugId
. This isn't returning any data in the second while loop. I would like to use JOINS
if possible but i am not really familiar with them. What are your thoughts?
My Code:
<?php
echo "<table>";
$resultBug = mysql_query("SELECT * FROM bugs WHERE projectId = '$projectId' ORDER BY bugId ASC");
echo "<tr> <th>Case Title</th> <th>Affected Browsers</th> </tr>";
while($rowBug = mysql_fetch_array( $resultBug )){
$bugId = $_POST['bugId'];
echo "<tr><td>";
$rowBugTitle = htmlspecialchars($rowBug['title']);
echo $rowBugTitle;
echo "</td><td>";
$resultAffectedBrowsers = mysql_query("SELECT * FROM affectedbrowsers WHERE bugId = '$bugId' ORDER BY id ASC");
while($rowAffectedBrowsers = mysql_fetch_array( $resultAffectedBrowsers )){
$affectedBrowsers = $rowAffectedBrowsers['label'];
echo $affectedBrowsers . " - ";
}
echo "</td></tr>";
}
echo "</table></div>";
?>