help me with ym query pls...

this is my code…

[php]<?php
$tmp_space=‘Billboard’;
$rr=0;
$querys=mysql_query(“SELECT * FROM slotmaintenance WHERE fldspace=’$tmp_space’ GROUP BY fldcode ORDER BY fldname”,$conn);
while($data=mysql_fetch_array($querys))
{
$myfldcode=$data[‘fldcode’];
$myfldspace=$data[‘fldspace’];
$myfldposition=$data[‘fldposition’];
$myfldname=$data[‘fldname’];
$myfldsize=$data[‘fldsize’];
$myfldstatus=$data[‘fldstatus’];
$myfldcontract=$data[‘fldcontract’];
$myfldsupplier=$data[‘fldsupplier’];
$myfldinstalled=$data[‘fldinstalled’];
$myndex=$data[‘ndex’];
$mytbltitle.=’



















‘.$mycount.’ Slot(s) ‘.$myfldname.’
Pos ‘.$tmp_space.’ Remarks Date Installed Size
‘.$myfldposition.’  ‘.$myfldsupplier.’  ‘.$myfldstatus.’  ‘.$myfldinstalled.’  ‘.$myfldsize.’ 

';
$mycount=$mycount + 1;
}
echo $mytbltitle;
?>
[/php]

here is the result


in my database



now this is what i want


  1. I would normalize the db:

put fldcode and fldname in a diffrent table and delete fldname from slotmaintenance. wounlt make a bigg difrence now but avoids errors in the future.

  1. u cannt use GROUP BY if u wanna have all results.

From there i know 2 ways to go on:

use a variable $oldfldcode and put the “

”-part inside an if($oldfldcode!=$myfldcode)

or use a first query and loop to just get the fldcode and fldname. and inside that loop use a second mysql_query and loop to get all rows WHERE fldcode=$myfldcode.

:lol:
Sponsor our Newsletter | Privacy Policy | Terms of Service