I hope there is a php genius here somewhere who can help me with this. I have a database table called baeir, it has the following fields:
b_id (primary k
as mentioned above, the following Google Maps tutorial answers your question ALMOST completely: http://code.google.com/apis/kml/articles/phpmysqlkml.html
unfortunately, it does not propose code for polygon parsing (which you will need, if you are managing farm areas display), but you can adapt the LinesString parsing method and achieve it. beware of properly embedding the outerBoundaryIs tag in the Polygon tag AND remember that you must duplicate the starting point for the polygon to be drawn correctly.
$lineNode = $dom->createElement('Polygon');
$placeNode = $placeNode->appendChild($lineNode);
$exnode = $dom->createElement('extrude', '1');
$lineNode->appendChild($exnode);
$almodenode =$dom->createElement(altitudeMode,'relativeToGround');
$lineNode->appendChild($almodenode);
$outerboundnode = $dom->createElement('outerBoundaryIs');
$placeNode = $placeNode->appendChild($outerboundnode);
$ringnode =$dom->createElement('LinearRing');
$placeNode = $placeNode->appendChild($ringnode);
// optional styletag colors the polygon
//$stylenode =$dom->createElement(styleUrl,'#transYellowPoly');
//$lineNode->appendChild($stylenode);
//Create a coordinates element and give it the value of the lng and lat columns from the results
//$coorNode = $dom->createElement('coordinates',$row['coordinates']);
$coorNode = $dom->createElement('coordinates',$coordinates);
$placeNode = $placeNode->appendChild($coorNode);