[nycphp-talk] for() question
Chris Bielanski
Cbielanski at inta.org
Tue Apr 20 15:00:34 EDT 2004
I'm not sure I understand what you're trying to do, but if I get the general
idea, may I suggest:
$i = 0;
while ($row = mysql_fetch_array($resultID,MYSQL_NUM)) {
$plot[$i]=$row;
$i++;
}
}
which should provide count($plot) arrays such that print_r($plot) returns:
Array {
[0] => Array ( [0] => pt01, [1] => pt02, [N] => pt0N),
[1] => Array ( [0] => pt11, [1] => pt12, [N] => pt1N),
[2] => Array ( [0] => pt21, [1] => pt22, [N] => pt2N)
...
[N] => Array ( [0] => ptN1, [1] => ptN2, [N] => ptNN),
}
and so forth
Is this the data structure you're after, or is something missing?
Thanks,
Chris Bielanski
Web Programmer,
International Trademark Association,
1133 Avenue of the Americas, 33rd Floor
New York, NY 10036
+1 (212) 642-1745, f: +1 (212) 768-7796
mailto:cbielanski at inta.org, www.inta.org
INTA -- 125 Years of Excellence
> -----Original Message-----
> From: Rafi Sheikh [mailto:Rafi.Sheikh at Ingenix.com]
> Sent: Tuesday, April 20, 2004 2:24 PM
> To: 'talk at lists.nyphp.org'
> Subject: [nycphp-talk] for() question
>
>
> Hi List.
>
> My status: Brain dead
> NEEDED: How do I assign the retrieved data to unique arrays?
>
> Henry and Dan form this list helped me to get at this stage where I am
> retrieving the data from a mysql table.
>
> Now, It is very embarrassing but after I get the data read in
> (code below),
> I for the love of PHP, can not make unique rows or
> dynamically assign the
> data. I tried the following:
> $plot=array();
> $i=0;
>
> while ($row = mysql_fetch_assoc($resultID)) {
>
> foreach($row as $field) {
> $plot[$i]=$field;
> $i++;
> }
>
>
> It seems to either go to the last row of data, or if I do:
> $data1=$array[0]);
>
> or so, I get one line which is fine but than, as soon I do:
> $data1=$array[0];
> $data2=$array[1];
> ... more like this...
>
> than at 4th or 5th $data5, etc. it tells me that it is
> undefined (going back
> to where all the data was read in the first iteration-I think)
>
> WHAT I AM TRYING TO DO:
> All I need is that the data I get read in (thx H & D), to get
> it assigned to
> an array dynamically or manually per row, which becomes my
> one set of data
> that I could use. So If I had 10 rows, I will get 10 unique
> arrays that I
> could use with jpgraph for a multi-line graph.
>
> I am afraid my novice status in PHP is not letting me write
> or understand a
> better "for or do..while" code that could do the job. Can you help?
>
>
> Rafi
>
>
>
>
> This e-mail, including attachments, may include confidential and/or
> proprietary information, and may be used only by the person
> or entity to
> which it is addressed. If the reader of this e-mail is not
> the intended
> recipient or his or her authorized agent, the reader is
> hereby notified that
> any dissemination, distribution or copying of this e-mail is
> prohibited. If
> you have received this e-mail in error, please notify the
> sender by replying
> to this message and delete this e-mail immediately.
> _______________________________________________
> talk mailing list
> talk at lists.nyphp.org
> http://lists.nyphp.org/mailman/listinfo/talk
>
More information about the talk
mailing list