Please brace yourselves for this, its rather long but the solution am looking for is simple and am sure it wont take long for you guys to get it.
I would like to make it as clear as crystal, please inform me where you feel confused.
$sql = "SELECT * FROM $dbtable WHERE job_id='$batch_nr' ORDER BY group_id ASC";
$result = mysql_query($sql ,$dbt);
Code: Select all
$total_records = mysql_num_rows($result);
$i=0;
while ($i < $total_records) {
/* To obtain the group_id */
$first=mysql_result($result,$i,"group_id");
/* To obtain the serial value which is composed of
* nr values and test results in a string.
*/
$serial=mysql_result($result,$i,"serial_value");
/*To remove the = and & characters in the string */
$keywords = preg_split ("/[\=\&]+/", "$serial");
$cols=count($keywords);
/* Test results are obtained from here */
for ($rol=2; $rol < $cols; $rol+=2){
$rname = $rname.$keywords[$rol].'#';
}
/* the nr numbers are obtained from here */
for ($kol=1; $kol < $cols; $kol+=2){
$peck = $peck .$keywords[$kol].'#';
}
$i++;
}
# To retrieve the nr numbers as an array
$nval = preg_split ("/[\#]+/", "$peck ");
array_pop( $nval);
$jack = 285285;
$rvalue = str_replace('-', 285285, "$rname");
# To retrieve the test results
$rval = preg_split ("/[\#]+/", "$rvalue");
array_pop( $rval);
$parameterselect = $param_gp;
$notes = $notes;
$lastgroup = '';
$depts = $db->Execute("SELECT $dbtable.serial_value,$dbtable.type,$dbtable.group_id,$dbtable.notes,$table.name,$table.nr,$table.normals,$table.msr_unit FROM $dbtable INNER JOIN $table ON $dbtable.group_id = $table.group_id WHERE $dbtable.job_id = '$batch_nr' ORDER BY group_id ASC, torder");
while($rows= $depts->FetchRow()){
// Print Group header
if ($rows['group_id'] != $lastgroup) {
//Display last subtotal if not first group
if ($lastnotes) {
echo '<tr>
<td width="160" height="10"></td>
</tr>';
echo '<tr>';
echo '<td height=10><FONT SIZE=2 FACE="Arial, Helvetica, sans-serif">Notes/Comments</FONT></td>'."\n";
echo '<td height=10 width=300><FONT SIZE=2 FACE="Arial, Helvetica, sans-serif">'.nl2br($lastnotes).'</FONT></td>'."\n";
echo '</tr>';
}
$lastnotes = $rows['notes'];
//Reset the subtotal
$subtotal = 0;
// Print Group Name
echo '<tr>
<td width="160" height="10"></td>
</tr>';
echo '<tr class=wardlistrow2 >';
echo '<td><FONT SIZE=2 FACE="Arial, Helvetica, sans-serif" ><u> '.$parametergruppe[$rows['group_id']].'</u></FONT></td>'."\n";
echo '<td> </td>'."\n";
echo '<td> </td>'."\n";
echo '<td> </td>'."\n";
echo '</tr>';
}
if ($rval[$counter] != $jack) {
/* Match up of the nr numbers */
if ($nval[$counter] == $rows['nr']) {
?>
<tr >
<td><FONT SIZE=2 FACE="Arial, Helvetica, sans-serif" > <?php echo $rows['name']; ?> </FONT></td>
<td><FONT SIZE=2 FACE="Arial, Helvetica, sans-serif" ><?php echo nl2br ($rval[$counter]); ?></FONT></td>
<td><FONT SIZE=2 FACE="Arial, Helvetica, sans-serif" > <?php echo $rows['msr_unit']; ?></FONT> </td>
<td><FONT SIZE=2 FACE="Arial, Helvetica, sans-serif" > <?php echo $rows['nr']; ?></FONT> </td>
<td><FONT SIZE=2 FACE="Arial, Helvetica, sans-serif" > <?php echo $nval[$counter]; ?></FONT> </td>
<td width="149" valign="top"><FONT SIZE=2 FACE="Arial, Helvetica, sans-serif" > <?php echo $rows['normals']; ?></FONT></td>
</tr>
<?php
}
}
//Add to subtotal
$subtotal++;
//Set the lastgroup value
$lastgroup = $rows['group_id'];
$counter++;
}
echo '<tr>
<td width="160" height="10"></td>
</tr>';
// Show the last subtotal row
echo '<tr>';
echo '<td height=10><FONT SIZE=2 FACE="Arial, Helvetica, sans-serif">Notes/Comments</FONT></td>'."\n";
echo '<td height=10 width=300 ><FONT SIZE=2 FACE="Arial, Helvetica, sans-serif">'.nl2br($lastnotes).'</FONT></td>'."\n";
echo '</tr>';
?>
</form>
</table>
Guys, The problem is that if I add an nr value then none of the tests show correctly they are mismatched.
Do you follow ?????