rocky86
08-01-2007, 02:57 AM
hi ppl I am new here hope to find some help around regarding php ok here go currently I having 2 table:
Districts Table
http://i189.photobucket.com/albums/z94/Aizen99/districit.jpg
Location Table
http://i189.photobucket.com/albums/z94/Aizen99/location.jpg
from the 2 table I need to do a php coding to compare the value against the 2 table which is the districts.startlat,districts.endlat,districts.star tlng and districts.endlng and the location table location.lat and location.lng and return the uname below is the php code I come out with can help me check if it is correct?
<?php
$temp="";
$sqlconnect=mysql_connect("localhost","hyperian_track","gsmtrack");
if(!$sqlconnect)
die(mysql_error());
mysql_select_db("hyperian_track", $sqlconnect);
if($_GET['postal']))
$postalcode=substr($_GET['postal'],0,2); //will return from 0 position 2 characters
$resultpostal=mysql_query("SELECT startlat,endlat,startlng,endlng FROM districts
WHERE districtno = $postalcode"); //get startlat,endlat,startlng,endlng of location
if($postalno = mysql_fetch_array($resultpostal))
{
$postalno=$row;
}
$resultname=mysql_query("SELECT uname FROM location,$postalno
WHERE location.lat < $postalno['startlat'] AND location.lat > $postalno['endlat'] AND location.lng < $postalno['startlng']
AND location.lng > $postalno['endlng']");
if($rowselect = mysql_fetch_array($resultname))
{
$temp[]=$rowselect;
}
foreach($temp as $result)
$reportname=$result;
echo '&$reportname&'; //send to actionscripts
}//end of if loops
mysql_close($con);
I want to know if from the statement one I create a variable and store all the sql query inside then I need to compare the stored sql query with the location table to get the uname so is my code correct finally I need to send it to actionscript to do the output
Districts Table
http://i189.photobucket.com/albums/z94/Aizen99/districit.jpg
Location Table
http://i189.photobucket.com/albums/z94/Aizen99/location.jpg
from the 2 table I need to do a php coding to compare the value against the 2 table which is the districts.startlat,districts.endlat,districts.star tlng and districts.endlng and the location table location.lat and location.lng and return the uname below is the php code I come out with can help me check if it is correct?
<?php
$temp="";
$sqlconnect=mysql_connect("localhost","hyperian_track","gsmtrack");
if(!$sqlconnect)
die(mysql_error());
mysql_select_db("hyperian_track", $sqlconnect);
if($_GET['postal']))
$postalcode=substr($_GET['postal'],0,2); //will return from 0 position 2 characters
$resultpostal=mysql_query("SELECT startlat,endlat,startlng,endlng FROM districts
WHERE districtno = $postalcode"); //get startlat,endlat,startlng,endlng of location
if($postalno = mysql_fetch_array($resultpostal))
{
$postalno=$row;
}
$resultname=mysql_query("SELECT uname FROM location,$postalno
WHERE location.lat < $postalno['startlat'] AND location.lat > $postalno['endlat'] AND location.lng < $postalno['startlng']
AND location.lng > $postalno['endlng']");
if($rowselect = mysql_fetch_array($resultname))
{
$temp[]=$rowselect;
}
foreach($temp as $result)
$reportname=$result;
echo '&$reportname&'; //send to actionscripts
}//end of if loops
mysql_close($con);
I want to know if from the statement one I create a variable and store all the sql query inside then I need to compare the stored sql query with the location table to get the uname so is my code correct finally I need to send it to actionscript to do the output