Author Topic: Got the query, Cant figure out the right code to display it..  (Read 215 times)

SBuzz

  • New Member
  • *
  • Posts: 3
  • Karma: 0
    • View Profile
Hi,

the following query:
PHP Code: [Select]
$query1 "SELECT d.value, c.value, d.user_id, (SQRT(POW((b.x - a.x), 2) + POW((b.y - a.y), 2))/1000) * 0.621 AS distance
 FROM postcodes a, postcodes b, wp_bp_xprofile_data c JOIN  wp_bp_xprofile_data d 
     ON c.user_id=d.user_id AND d.field_id=1 
 WHERE a.outcode = '"
.$postcode."' AND b.outcode = c.value
 HAVING (distance < '"
.$area."')
ORDER BY distance asc "
;


when i run it on the database, returns exactly what i want. 

I just need the php code to display all the info.

My code (trunkated):

PHP Code: [Select]
// display results
	
while (
$list mysql_fetch_array($result1)) {
    
$user_postcode $list['value'];
	
$distance $list['distance'];
	
$distance round($distance);
echo 
"<td colspan=\"3\" align=\"left\"><strong>$user_postcode</strong></td>";


Will display only one of the 'value', from the wp_bp_xprofile_data table..

Any help? Any more info you need?

Thanks

SBuzz

  • New Member
  • *
  • Posts: 3
  • Karma: 0
    • View Profile
Re: Got the query, Cant figure out the right code to display it..
« Reply #1 on: March 20, 2012, 09:01:13 AM »
In short,  how to define the *other* returned 'value' to a $variable?

SBuzz

  • New Member
  • *
  • Posts: 3
  • Karma: 0
    • View Profile
Re: Got the query, Cant figure out the right code to display it..
« Reply #2 on: March 20, 2012, 09:10:11 AM »
I got it..

Define them 1st using AS, then getting them back with

mysql_fetch_assoc.

Thanks for the help. =)