I first query a table called Points for all rows. This table holds x and y points in longitude and latitude. I then while loop the results to get each row. I then want to run a new query on a second table called segments in which I will use the stored x,y data as a condition or variable in the query. I can get this to run for one point but not for all the points. Can you use data from one table to use for a query in another table? I would try to use JOIN but the tables do not relate, I just need to evaluate each point, the problem is there are hundreds of points. Here is my code.
$pointresults = mysql_query("SELECT * FROM points");
$num_points = mysql_num_rows($pointresults);
if($num_points == 0) {
echo "No Points in Table, There is an Error!";
}
else {
// get each row
while($mypointrow = mysql_fetch_array($pointresults))
{
$thelon = $mypointrow['Longitude'];
$thelat = $mypointrow['Latitude'];
$result = "SELECT poly_id, Segment_id FROM segments WHERE ( longa > $thelng OR longb > $thelng )
AND ( (lata > $thelat AND latb < $thelat )
OR (latb > $thelat AND lata < $thelat ) )";
$result2=mysql_query($result);
$resultnumrows = mysql_num_rows($result2);
Any help would be appreciated.







Bookmarks