I tried it but that's not going to work as the task, defect and part are all from seperate tables. The output it's trying to create is similar to this
taskno description
1 oil change
defects
filter
parts
new filter
taskno description
2 etc
I hope this makes sense. here is the whole code for this
<?
$db = mysql_connect ("localhost", "root", "orange");
mysql_select_db ("camco", $db);
$query = "SELECT * FROM lambitems WHERE servicetypeno = '$row9[21]' ORDER BY taskno";
$res = mysql_query ($query, $db);
for ($i = 0; $i < mysql_num_rows ($res); $i++) {
$row = mysql_fetch_row ($res);
echo '<table border=1>';
echo '<tr><td><font face=arial size=2><b>Task No</td><td><font face=arial size=2><b>Task Description</td><td><font face=arial size=2><b>Nature</td><td><font face=arial size=2><b>Interval</td><td><font face=arial size=2><b>Cert. Person</td><td><font face=arial size=2><b>Hours</td><td><font face=arial size=2><b>Date</td></tr>';
printf ("<tr><td><input type=\"READONLY\" name=\"taskno\" size=\"6\" value=\"$row[3]\"></td>\n");
printf ("\n<td><font face=arial size=2>%s</td>\n", $row[1], $row[1], $row[1]);
printf ("\n<td><font face=arial size=2>%s</td>\n", $row[4], $row[4], $row[4]);
printf ("\n<td><font face=arial size=2>%s\n", $row[5], $row[5], $row[5]);
printf ("<input type=\"hidden\" name=\"taskno\" size=\"6\" value=\"$row[3]\"></td>\n");
?>
<?
$db = mysql_connect ("localhost", "root", "orange");
mysql_select_db ("camco", $db);
$query2 = "SELECT * FROM workdetail WHERE custno = '$row9[6]' AND techno = '$row[3]' ORDER BY techno";
$res2 = mysql_query ($query2, $db);
$row2 = mysql_fetch_row ($res2);
printf ("\n<td><font face=arial size=2>%s</td>\n", $row2[15], $row2[15], $row2[15]);
printf ("\n<td><font face=arial size=2>%s</td>\n", $row2[3], $row2[3], $row2[3]);
printf ("\n<td><font face=arial size=2>%s\n", $row2[5], $row2[5], $row2[5]);
echo '<tr><td></td><td><font face=arial size=2><b>Defect Found</td><td><font face=arial size=2><b>Description</td></tr>';
?>
<?
$db = mysql_connect ("localhost", "root", "orange");
mysql_select_db ("camco", $db);
$query3 = "SELECT * FROM defects WHERE jobno = '$row9[6]' AND taskno = '$row[3]' GROUP BY taskno";
$res3 = mysql_query ($query3, $db);
$row3 = mysql_fetch_row ($res3);
printf ("\n<tr><td></td>\n", $row3[3], $row3[3], $row3[3]);
printf ("\n<td><font face=arial size=2>%s</td>\n", $row3[4], $row3[4], $row3[4]);
printf ("\n<td><font face=arial size=2>%s</td></tr>\n", $row3[5], $row3[5], $row3[5]);
?>
<?
$db = mysql_connect ("localhost", "root", "orange");
mysql_select_db ("camco", $db);
$query4 = "SELECT * FROM parts WHERE jobno = '$row9[6]' AND taskno = '$row[3]'";
$res4 = mysql_query ($query4, $db);
$row4 = mysql_fetch_row ($res4);
echo '<tr><td></td><td></td><td><font face=arial size=2><b>Part</td><td><font face=arial size=2><b>Part No</td><td><font face=arial size=2><b>Cost</td></tr>';
printf ("\n<tr><td></td>\n", $row4[3], $row4[3], $row4[3]);
printf ("\n<td></td>\n", $row4[4], $row4[4], $row4[4]);
printf ("\n<td><font face=arial size=2>%s</td>\n", $row4[5], $row4[5], $row4[5]);
printf ("\n<td><font face=arial size=2>%s</td>\n", $row4[6], $row4[6], $row4[6]);
printf ("\n<td><font face=arial size=2>%s</td></tr>\n", $row4[7], $row4[7], $row4[7]);
echo '</table>';
echo '<table border=0><tr><td><br></td></tr></table>';
}
mysql_free_result ($res);
mysql_free_result ($res2);
mysql_free_result ($res3);
mysql_free_result ($res4);
mysql_close ($db);
mysql_close ($db);
mysql_close ($db);
mysql_close ($db);
?>
It draws out the task nos then fills in the info relevent to that task no, then goes onto the next taskno until there are no tasks left. What i need it to do is pull out all the defects not just one and all the parts that relate to the taskno and then go onto the next taskno and pull the defects and parts. I hope this makes sense, thanks Martin