[Mapserver-users] Please check my code (php_mapscript / mySQL )
Ryan, Adam
ARyan at co.linn.or.us
Wed Jul 21 14:02:53 PDT 2004
Bonner,
I'll take a stab though I've never done what you're doing. Just some
comments on your code logic. I would promote two of your lines and demote
one from the loop and add a '</table>' so it reads something like this...
if($result)
{
print "<table border='1' summary=''>";
print " <tr><th>ID</th><th>XCOORD</th><th>YCOORD</th></tr>";
$img = $map->draw();
$layer = $map->getLayerByName('test');
for ($i = 0; $i < $numrows; $i++)
{
$value = mysql_fetch_array($result);
$point = ms_newPointObj();
$point->setXY($value[20],$value[21]);
$point->draw($map, $layer, $img, 0 ,'map image');
$point->free();
print
"<tr><td>$value[0]</td><td>$value[20]</td><td>$value[21]</td></tr>";
}
}
$url = $img->saveWebImage();
echo "</table><img src='$url' border= '1' alt='map image'>";
No idea if that will change thinks at all, but it might.
Also, are you getting the points that you should be getting? Does
$value[20] and [21] confirm that your search performed correctly?
Adam Ryan
GIS Analyst
Linn County GIS Department
County Courthouse / Room 25
300 SW Fourth Ave.
Albany, OR 97321
541.812.8760
aryan at co.linn.or.us
-----Original Message-----
From: BONNER S KARGER [mailto:bskarger at students.wisc.edu]
Sent: Wednesday, July 21, 2004 12:41 PM
To: Mapserver User Group
Subject: [Mapserver-users] Please check my code (php_mapscript / mySQL)
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
_______________________________________________
Mapserver-users mailing list
Mapserver-users at lists.gis.umn.edu
http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
More information about the MapServer-users
mailing list