I might be going about this the wrong way but this is what I have so far:

I am creating a html table for a graveyard layout and have a mysql table with the persons details and have another mysql table for the location in the graveyard/html table.

I am using a simple join on the mysql tables and if there is one person in one plot/html cell all is OK but sometimes there are 3 or 4 people in each plot/html cell and they come out as seperate cells on the html table.

This is the information for each person
Code:
CREATE TABLE IF NOT EXISTS `individual` (
  `ID` int(3) NOT NULL AUTO_INCREMENT,
  `table_cell` int(3) NOT NULL,
  `surname` varchar(20) NOT NULL,
  `forename` varchar(20) NOT NULL,
   PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=28 ;
This is for the location in the html table
Code:
CREATE TABLE IF NOT EXISTS `table_cell` (
  `ID` int(3) NOT NULL AUTO_INCREMENT,
  `cell_number` smallint(3) DEFAULT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=25 ;
This is my SQL query
PHP Code:
$query  "SELECT
table_cell.ID,
table_cell.cell_number,
individual.table_cell,
individual.surname,
individual.forename
FROM
table_cell,
individual
WHERE
table_cell.ID = individual.table_cell
ORDER BY
table_cell.ID ASC"
;

$result = @mysql_query$query );
if(
$result === FALSE) {
die(
mysql_error());
}

$i 0;
echo 
"<tr>\n";
while(
$row mysql_fetch_array($result)){
if(
$i and $i 12 == 0) {
 echo 
"</tr>\n<tr>\n";
}

// Bodge for empty cell
if ( empty($row['cell_number'] )) { $number "<br/>"; } else $number $row['cell_number'] ;
echo 
"<td align=\"left\">$number <a href=\"display.php?stone=".$row['headstone']."\">".$row['forename']." ".$row['surname']."</a></td>\n";
    
$i++;
  } 
HTML output
HTML Code:
<tr>
<td align="left">288 <a href="display.php?stone=000">D Gipson</a></td>
<td align="left">288 <a href="display.php?stone=000">N Gipson</a></td>
<td align="left">262 <a href="display.php?stone=000">John Fisher</a></td>
<td align="left">236 <a href="display.php?stone=000">R Reynolds</a></td>
<td align="left">210 <a href="display.php?stone=000"> Path</a></td>
<td align="left">158 <a href="display.php?stone=000"> </a></td>
<td align="left"><br/> <a href="display.php?stone=000"> </a></td>
<td align="left"><br/> <a href="display.php?stone=000"> </a></td>
<td align="left"><br/> <a href="display.php?stone=000"> </a></td>
<td align="left"><br/> <a href="display.php?stone=000">Tree stump</a></td>
<td align="left">27 <a href="display.php?stone=000">William Jacklin</a></td>
<td align="left">27 <a href="display.php?stone=000">Georgina </a></td>
</tr>
As you can see the first two items should be in one cell and the last two items should be in another cell.
What would be the best way to overcome the problem of extra html cell generation?