# Newbie here need help with PHP MYSQL

**URL:** <https://forum.kirupa.com/t/newbie-here-need-help-with-php-mysql/234176>\
**Category:** programming\
**Created:** [July 31, 2007, 7:49am UTC](https://forum.kirupa.com/t/newbie-here-need-help-with-php-mysql/234176 "2007-07-31T07:49:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rocky86](https://avatars.discourse-cdn.com/v4/letter/r/c2a13f/32.png) [@rocky86](https://forum.kirupa.com/u/rocky86)\
**Post date:** [July 31, 2007, 7:49am UTC](https://forum.kirupa.com/t/newbie-here-need-help-with-php-mysql/234176/1 "2007-07-31T07:49:16Z")

</div>

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.startlng 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 but it just does not look correct at all

```php

<?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($row = mysql_fetch_array($resultpostal))
  {
   $postalno=$row; // store each record in an array
  }
 
 
$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($row = mysql_fetch_array($resultname))
  {
   $temp[]=$row;
  }
 
  foreach($temp as $key=>$extract)
  $reportname=$reportname.$key."=".$extract."&";

  echo $reportname;
}//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 can I just declare and variable and compare it eg:location.lat \> $postalno.endlat
