I need to select multiple rows of xy data from two seperate tables and then store the values in two seperate array's. I think I have done that. However, I then need to use all values in each array in a function that is outside of the while loop for each query. The function only returns one value, instead of all of the values that should be stored. Here is some of the code:
$link = mysql_connect("localhost", "root", "");
mysql_select_db("database", $link);
$bndresult = mysql_query("SELECT * FROM polygon
", $link);
$num_rows = mysql_num_rows($bndresult);
if($num_rows == 0) {
echo "No rows!";
}
else {
// get each row
while($myrow = mysql_fetch_array($bndresult, MYSQL_BOTH))
{
$x = $myrow[Lon];
$y = $myrow[Lat];
$myPolygon = array("x," => $x, "y" => $y);
}
$result = mysql_query("SELECT * FROM point", $link);
$num_rows2 = mysql_num_rows($result);
if($num_rows2 == 0) {
echo "No rows!";
}
else {
// get each row
while($myrow2 = mysql_fetch_assoc($result))
{
$xpoint = $myrow2[Lon];
$ypoint = $myrow2[Lat];
$point = array("x" => $xpoint, "y" => $ypoint);
}
foreach($point as $key => $point) {
echo "$key ($point) is " . $pointLocation->pointInPolygon($point, $myPolygon) . "<br>";
}
This loop does not work correctly because it only loops for one of the arrays how do I loop for both?
Posts: 1
Joined: Sat Feb 23, 2008 9:17 am
Private message