View Full Version : Need help how come is display one record!!
rocky86
August 4th, 2007, 03:39 AM
Hi ppl I need help with my php basically I manage to get my php to display the uname that matches the sql condition however it only return 1 record when there are 2 record that match the condition how do I make it display all record that matches the condition instead of displaying just one?
This is my code:
$resultpostal=mysql_query("SELECT location.uname,location.uid FROM location,districts WHERE districts.districtno ='56' AND
location.lat BETWEEN districts.startlat AND districts.endlat AND location.lng BETWEEN districts.startlng AND districts.endlng");
$counterx=0;
if($row=mysql_fetch_array($resultpostal)){
foreach($row as $col_value){
$temp[$counterx]=$col_value;
$counterx++;
}
$report.="uid"."=".$temp[0]."&";
$report.="uname"."=".$temp[1]."&";
eirche
August 4th, 2007, 11:59 AM
that's odd. can you post those 2 matching records from `location` table, and the 1 record from `district` where `districtno` = 56? in full.
btw you don't need $counterx, just do $temp[]=$col_value;
rocky86
August 4th, 2007, 02:11 PM
that's odd. can you post those 2 matching records from `location` table, and the 1 record from `district` where `districtno` = 56? in full.
btw you don't need $counterx, just do $temp[]=$col_value;
Location Table
http://i189.photobucket.com/albums/z94/Aizen99/loca.jpg
As you can see it should return me the 3 and 4 record of it I test the sql statement it does return this 2 record however php only can display the 3 record which is Kurt instead of both Kurt and Batista
Districts Table
http://i189.photobucket.com/albums/z94/Aizen99/distirct.jpg
eirche
August 4th, 2007, 02:19 PM
//change
if($row=mysql_fetch_array($resultpostal))
// to
while($row=mysql_fetch_array($resultpostal))
rocky86
August 4th, 2007, 10:12 PM
//change
if($row=mysql_fetch_array($resultpostal))
// to
while($row=mysql_fetch_array($resultpostal))
I try that too but it still does not work at all iszit the way I return the value is wrong?
eirche
August 4th, 2007, 10:26 PM
while($row=mysql_fetch_array($resultpostal)){
print_r($row);
}
rocky86
August 5th, 2007, 04:20 AM
while($row=mysql_fetch_array($resultpostal)){
print_r($row);
}
This statement is to see if it print out the record?
eirche
August 5th, 2007, 12:50 PM
This statement is to see if it print out the record?
why don't you just go and try it? i leave it to you to figure out the rest.
rocky86
August 6th, 2007, 01:11 AM
why don't you just go and try it? i leave it to you to figure out the rest.
I understand that this mysql_fetch_array () function
is able to just fetch the first row but how do I make it that it is able to fetch not only the first row but all the row that matches the sql condition?
rocky86
August 6th, 2007, 01:17 AM
Hi ppl I need help with my php basically I manage to get my php to display the uname that matches the sql condition however it only return 1 record when there are 2 record that match the condition how do I make it display all record that matches the condition instead of displaying just one?
This is my code:
$resultpostal=mysql_query("SELECT location.uname,location.uid FROM location,districts WHERE districts.districtno ='56' AND
location.lat BETWEEN districts.startlat AND districts.endlat AND location.lng BETWEEN districts.startlng AND districts.endlng");
$counterx=0;
if($row=mysql_fetch_array($resultpostal)){
foreach($row as $col_value){
$temp[$counterx]=$col_value;
$counterx++;
}
$report.="uid"."=".$temp[0]."&";
$report.="uname"."=".$temp[1]."&";
echo $report;
I understand that mysql_fetch_array only fetch the first row how do I make my code to make it able to take not just the first row but all the row matches the sql condition?
simplistik
August 6th, 2007, 08:21 AM
dont' cross-post
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.