M
MarcusinMD author
Hello again, I have worked my way through our entire interface with this program and it works pretty well. Looks like it will be on the purchase list in a few days. The question I have is a bit complicated (for me at least with my limited php and mysql knowledge) The data that is collected from the interface we created with this program needs to be used to generate map points (using yahoo maps). I have the data generated from this softwares interface and I can access it perfectly with the code snippet below but only with fixed settings that I choose. I want to be able to use the phprunner's interface search engine query results to generate the data used to create the map points.
<?php function format_date($datetime) {
#match day/month/year hour:minute:seconds
preg_match("/(\d+)\/(\d+)\/(\d+)/",$datetime,$match); #reformat date string
$date = "$match[3]/$match[2]/$match[1]";
return $date;
} echo <<<EOB
<html>
<head>
<script type="text/javascript"
src="http://api.maps.yahoo.com/ajaxymap?v=3.0&appid=**************************************--">;
</script>
<style type="text/css">
#mapContainer {
height: 600px;
width: 800px;
}
</style>
</head>
<body>
<div align=center>
</script>
<div id="mapContainer"></div> <script type="text/javascript">
// Create a lat/lon object
var myPoint = new YGeoPoint(39.5756050,-76.9816802);
//var myTitle = new YAnnotation("Easternuswx.com Snowfall Plotter","",""); // Create a map object
var map = new YMap(document.getElementById('mapContainer'),YAHOO_MAP_SAT);
// Add a pan control
map.addPanControl();
// Add a slider zoom control
map.addZoomLong();
// Display the map centered on a latitude and longitude
map.drawZoomAndCenter(myPoint, 11);
map.addTypeControl(); function createYahooMarker(geopoint, num, member, ballon) {
var myImage = new YImage();
myImage.src = 'http://www.easternuswx.com/snowplotter07/snowflake_icon3.gif';;
//myImage.size = new YSize(30,20);
myImage.size = new YSize(30,20);
myImage.offsetSmartWindow = new YCoordPoint(0,0);
var marker = new YMarker(geopoint,myImage);
//var swtext = "Marker <b> " + num + "</b>";
var swtext = ballon;
var label= member;
marker.addLabel(label);
YEvent.Capture(marker,EventsList.MouseClick,
function() { marker.openSmartWindow(swtext) });
return marker;
} var i = 0; var bounds = map.getBoundsLatLon();
var height = bounds.LatMax - bounds.LatMin;
var width = bounds.LonMax - bounds.LonMin; EOB; // Setup the database
$hostname = "localhost"; // database host
$username = ""; // database username
$password = ""; // database username's password
$db_name = ""; // database name
$admin_email = ""; // contact email to display on connection errors // Connect to server
$linkID = @mysql_connect($hostname, $username, $password) or die("MySQL <strong>server</strong> connection failed; please advise ".$admin_email); // Connect to database
@mysql_select_db($db_name, $linkID) or die("MySQL <strong>database</strong> connection failed; please advise ".$admin_email); $gstrSQL = "select `_snowstorms`.`ID`, `_snowstorms`.`comments`, `_snowstorms`.`snowstorm_date`, `_snowstorms`.`snowstorm_total`, `_snowstorms`.`precip_type`, `_snowstorms`.`ID1`, `_members`.`login_name`, `_members`.`city`, `_members`.`state`, `_members`.`longitude`, `_members`.`latitude` From `_snowstorms` inner join `_members` on `_snowstorms`.`ID` = `_members`.`ID` where `_snowstorms`.`snowstorm_date` = '2007-12-02'"; $query = sprintf($gstrSQL); $resultID = @mysql_query($query);
$row_count = 0;
for ($i = 0; $i < mysql_num_rows($resultID); $i++)
{
$row = mysql_fetch_assoc($resultID);
if (!empty($row[longitude]))
{
$lon = $row[longitude];
$lat = $row[latitude];
$member = $row[login_name];
$snowtotal = $row[snowstorm_total];
$comments = $row[comments];
$snowdate = $row[snowstorm_date];
// $snowdate = $snowdate->format("m-d-Y");
$ballon_text = $snowdate."<BR>".$member."<BR>";//$comments;
echo <<<EOB var GeoPoint = new YGeoPoint($lat,$lon);
var marker = createYahooMarker(GeoPoint,$i,'$snowtotal','$ballon_text');
map.addOverlay(marker); EOB; // echo $longitude[$i];
// echo "<br>";
// Increment non-empty row counter
$row_count++;
}
}
// Free the memory used by the query result
mysql_free_result($resultID);
// Close database connection
mysql_close($linkID); echo <<<EOB
</script> </DIV ALIGN>
</body>
</html>
EOB;
?> To get started I edited the already generated php code from a custom list page created by phprunner. AT the end of the "...list.php" file I added the above code removing all of the database connection code (because phprunner already handles that for me) I am hoping that I can just drop the correct variable into the fields below and be on my way but I cannot figure out what this should be: This is how I query the database: $gstrSQL = "select `_snowstorms`.`ID`, `_snowstorms`.`comments`, `_snowstorms`.`snowstorm_date`, `_snowstorms`.`snowstorm_total`, `_snowstorms`.`precip_type`, `_snowstorms`.`ID1`, `_members`.`login_name`, `_members`.`city`, `_members`.`state`, `_members`.`longitude`, `_members`.`latitude` From `_snowstorms` inner join `_members` on `_snowstorms`.`ID` = `_members`.`ID` where `_snowstorms`.`snowstorm_date` = '2007-12-02'"; $query = sprintf($gstrSQL); $resultID = @mysql_query($query);
$row_count = 0;
for ($i = 0; $i < mysql_num_rows($resultID); $i++) The bolded areas are what I do not know and need to get the correct variable name (the one generated by phprunner) or what are the variables that phprunner uses for $query = sprintf($gstrSQL); so that I can use it in my code above. I hope this is enough info, I have searched for about an hour through all the posts but cannot seem to find anything that may pertain to this. Thank You!
|
|