Current location: Hot Scripts Forums » Programming Languages » PHP » How to make the php code to show not just the first record?


How to make the php code to show not just the first record?

Reply
  #1 (permalink)  
Old 08-06-07, 12:47 AM
aizen86 aizen86 is offline
Newbie Coder
 
Join Date: Aug 2007
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
How to make the php code to show not just the first record?

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 I understand that my code can only return the first row instead of the second or third row that matches the condition my question is how to modify my code to make it able to display not only the first but all of the row that fulfill the sql condition?

PHP Code:

$resultpostal=mysql_query("SELECT location.uname,location.uid FROM location,districts WHERE districts.districtno ='57' AND

location.lat BETWEEN districts.startlat AND districts.endlat AND location.lng BETWEEN districts.startlng AND districts.endlng"
);

$counterx=0;
while(
$row=mysql_fetch_array($resultpostal)){
foreach(
$row as $col_value){
$temp[$counterx]=$col_value;
$counterx++;
}


  
$report.="uid"."=".$temp[0]."&";
  
$report.="uname"."=".$temp[1]."&"
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 08-06-07, 01:26 AM
daveganley daveganley is offline
Newbie Coder
 
Join Date: Jun 2003
Location: London UK
Posts: 99
Thanks: 0
Thanked 0 Times in 0 Posts
Have you printed the array yet?

PHP Code:

print_r($temp); 

if there is more values you'll see them, they will be indexed as 2 and 3

echo $temp[2];
echo $temp[3];

Dave
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 08-06-07, 01:54 AM
mab's Avatar
mab mab is offline
Community VIP
 
Join Date: Oct 2005
Location: Denver, Co. USA
Posts: 2,674
Thanks: 0
Thanked 0 Times in 0 Posts
aizen86, your two other similar/duplicate threads on this same topic have been deleted.

Please only create one thread for each problem.
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 08-06-07, 02:37 AM
aizen86 aizen86 is offline
Newbie Coder
 
Join Date: Aug 2007
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
I only see the first row of the value being fetched the rest was not display
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP inside JavaScript? pikaz JavaScript 20 07-10-10 01:55 AM
Need help finding PHP code errors Elle0000 PHP 4 10-08-06 02:31 PM
Conception of you php code gigi_online Job Offers & Assistance 5 10-01-05 07:35 PM
How to Make my Php output write static Html files cebuy PHP 1 02-04-05 06:52 AM


All times are GMT -5. The time now is 01:24 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.