looping in php

This is a discussion on looping in php within the PHP Language forums, part of the PHP Programming Forums category; william.clarke@gmail.com wrote: >>> $result = mysql_query(some_query); >>> while(mysql_fetch_array($result,MYSQL_ASSOC){ >>&...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #11 (permalink)  
Old 04-20-2006
Rik
 
Posts: n/a
Default Re: looping in php

william.clarke@gmail.com wrote:
>>> $result = mysql_query(some_query);
>>> while(mysql_fetch_array($result,MYSQL_ASSOC){
>>> //do stuff with it
>>> }

>> In the below, say I did whatever I wanted to do to with this record, ie.,
>> retrived a city to a temp variable. How do I move or goto the next

record?

That's what you do with mysql_fetch_array().

> As milahu and Rik said this is PHP looping through a result
> set...(maybe not in the VB sense). There isn't a direct equivalent to
> the VB6 recordset, but you don't need one.



Don't know much about VB, but if you want to handle it as a complete
recordset: instead of processing the rows one by one:

$myrecordset = array();
while($row = mysql_fetch_array($result,MYSQL_ASSOC){

$myrecordset[] = $row;
}

Et voilą, a multidimensional array to abuse as you which.

Grtz,
--
Rik Wasmus


Reply With Quote
  #12 (permalink)  
Old 04-22-2006
Jim Whitaker
 
Posts: n/a
Default Re: looping in php

Thanks for all replies, I finally figured out looping in php.
"Rik" <luiheidsgoeroe@hotmail.com> wrote in message
news:e27hua$i4k$1@netlx020.civ.utwente.nl...
> william.clarke@gmail.com wrote:
> >>> $result = mysql_query(some_query);
> >>> while(mysql_fetch_array($result,MYSQL_ASSOC){
> >>> //do stuff with it
> >>> }
> >> In the below, say I did whatever I wanted to do to with this record,

ie.,
> >> retrived a city to a temp variable. How do I move or goto the next

> record?
>
> That's what you do with mysql_fetch_array().
>
> > As milahu and Rik said this is PHP looping through a result
> > set...(maybe not in the VB sense). There isn't a direct equivalent to
> > the VB6 recordset, but you don't need one.

>
>
> Don't know much about VB, but if you want to handle it as a complete
> recordset: instead of processing the rows one by one:
>
> $myrecordset = array();
> while($row = mysql_fetch_array($result,MYSQL_ASSOC){
>
> $myrecordset[] = $row;
> }
>
> Et voilą, a multidimensional array to abuse as you which.
>
> Grtz,
> --
> Rik Wasmus
>
>
>



Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 12:16 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0