Jump to content

help with this php mysql query code


svgmx5

Recommended Posts

Hey everyone,

 

im having problems querying the results from the database using this query....

$get_points = mysql_query("SELECT * FROM points WHERE ACOS(
												 (SIN(PI() * '41.896301269531' / '180') * SIN(PI() * latitude / '180')) +
												 (COS(PI() * '41.896301269531' /'180') * 
												  COS(PI() * latitude / '180') * 
												  COS(PI() * longitude / '180' - PI() * '-88.744201660156' / '180'))
												 )* '180' / PI() * '60' * '1.1515' <= '80'") or die(mysql_error());

 

Basically what it does it checks the for location with in 80 miles of the lat and long coordinates.

 

The problem is no result are showing up. I know there are locations because i tested this as an sql code in my database and it ran perfectly, but i can't get it to work using php..

 

I get no errors, nothing.

 

can anyone help me out?

Link to comment
Share on other sites

Heres't the table that should hold the results, along with the rest of the code


<table width="604" cellspacing="0" cellpadding="5" border="0" id="home-listing">
    <tr class="tb-heading">
            <td width="171"><strong>Building Name</strong></td>
            <td width="147"><strong>Architecht</strong></td>
            <td width="66"><strong>Date</strong></td>
            <td width="97"><strong>Building Type</strong></td>
            <td width="73"><strong>Style</strong></td>
    </tr>
    <?php
$get_points = mysql_query("SELECT * FROM points WHERE ACOS(
													 (SIN(PI() * '41.896301269531' / '180') * SIN(PI() * latitude / '180')) +
													 (COS(PI() * '41.896301269531' /'180') * 
													 COS(PI() * latitude / '180') * 
													 COS(PI() * longitude / '180' - PI() * '-88.744201660156' / '180'))
													 )* '180' / PI() * '60' * '1.1515' <= '$radius'") or die(mysql_error());
$num_of_records = mysql_num_rows($get_points);

if($num_of_points!=0){
          while($points = mysql_fetch_assoc($get_points)){
    ?>
     <tr>
            <td><?php echo $points['name'] ?></td>
             <td></td>
             <td><?php echo $points['date'] ?></td>
             <td>Residential Multi- Family</td>
             <td>Modern-Expresionist</td>
       </tr>
     <?php	
	}
     }else{
     ?>
        <tr>
            <td colspan="5">NO results found</td>
       </tr>
    <?php	
}
    ?>
</table>

 

Link to comment
Share on other sites

That's a different query string. The one you posted first had no variables in it. How do you expect to get help if you don't post the actual code that's producing the problem?

 

Remove the query string from the query execution, form it in a variable and echo it to make sure the variable holds the value that you'd expect it to hold.

 

$query = "query string";
echo $query;
$get_points = mysql_query($query) or die( mysql_error() );

Link to comment
Share on other sites

well i'm sorry about my small mistake.....

 

anyways even with or with out the variables there is nothing..and just to clear it up i had left a variable in  there but then removed it to test it..

 

My point is i tested it with out variables so the '$radius' variable is not there its '80' an actual number

Link to comment
Share on other sites

i figured it out..it was the smallest of mistakes and i can't believei missed it...

 


$num_of_records = mysql_num_rows($get_points);

if($num_of_points!=0){

     }

 

Those 2 lines where way different.....

 

I'm sorry for t his ppl and thank you for your help

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.