[Mapserver-users] Please check my code (php_mapscript / mySQL)
BONNER S KARGER
bskarger at students.wisc.edu
Wed Jul 21 12:40:34 PDT 2004
Still working on this...
trying to get mapserver to plot points from coordinates pulled from a mySQL table. I'll worry about making the shapefile/dbf later...for now I just want them to appear on the map! I'm using MS 4.2 php_mapscript ($Revision: 1.194.2.3 $ $Date: 2004/05/13 21:37:44 $) .
HERE IS MY CODE:
-------------------------------
$record = ("SELECT * FROM $dbtable1, $dbtable2 WHERE $xvar < 0 AND $dbtable1.$id = $dbtable2.$id AND $sort = '9';");
$result = mysql_db_query($dbname,$record);
$numrows = mysql_num_rows($result);
if($result)
{
print "<table border='1' summary=''>";
print " <tr><th>ID</th><th>XCOORD</th><th>YCOORD</th></tr>";
for ($i = 0; $i < $numrows; $i++)
{
$value = mysql_fetch_array($result);
$point = ms_newPointObj();
$point->setXY($value[20],$value[21]);
$img = $map->draw();
$layer = $map->getLayerByName('test');
$point->draw($map, $layer, $img, 0 ,'map image');
$url = $img->saveWebImage();
$point->free();
print "<tr><td>$value[0]</td><td>$value[20]</td><td>$value[21]</td></tr>";
}
}
echo "<img src='$url' border= '1' alt='map image'>";
------------------------------------------
What happens is this: the results consist of 2 records (confirmed by echoing "$numrows"). The FIRST point gets plotted correctly, but the second one isn't. Also, the first point is black, when it should be styled red. If I get just 1 result, the point is plotted correctly, and is the correct color (red).
The map file has this for the "test" layer def:
LAYER
NAME "test"
TYPE POINT
STATUS ON
CLASS
NAME "Meat Proc. Residuals"
TEMPLATE "test.php-cgi"
STYLE
COLOR 255 0 0
SYMBOL "circle"
SIZE 8
END #style
END #class
END #layer
Any ideas?
Thanks!
^^Bonner
More information about the MapServer-users
mailing list