NYCPHP Meetup

NYPHP.org

[nycphp-talk] creating unique array per row

Daniel Convissor danielc at analysisandsolutions.com
Tue Mar 16 11:38:08 EST 2004


Hi Rafi:

Henry's answer expands upon the answer I gave you the other day on your 
related question.  Henry's change to accommodate your new question is to 
create an array of an array for each row.  His code can be simplified a 
tad as well by dropping the $cont counter variable since PHP automatically 
assigns the keys...

$table_rows = array ();
while ($row = mysql_fetch_array($result)) {
    $table_rows[] = $row;
}

That could even be cut down a step by assigning the data directly...

$table_rows = array ();
while ($table_rows[] = mysql_fetch_array($result));

--Dan


> After this $table_rows will be an array of arrays. The while structure adds an 
> array ($row) for each row in your table (table_name).
> 
> You can get the values with a for{} structure if you wish.
> 
> Hope this helps,
> Henry
> 
> On Tuesday 16 March 2004 14:02, Rafi Sheikh wrote:
> > Hi list.
> >
> > BASIC: Apache 1.3.29, PHP 4.3.4, MySQL 4 on WIN2K-Pro
> > BACKGROUND:
> > 		Need to create multiple line graph (no x axis value but
> > multiple Y-axis values) using JPGRPAH.
> > PROBLEM:
> > 		I have a table of fixed # of col. (6) with fixed # of rows
> > (6).  How do I get the data from MySQL and create one unique array for each
> > row (ea. row -> one new array -> plot for one line)
> >
> > DATA EXAMPLE:
> > Category	val1	val2	VAL3
> > abc		89	78	99
> > efg		99	90	91
> > hij		100	99	90
> >
> > Note: Trying to have abc, efg, hij as Y-axis separate data plot-in this
> > case I will have 3 arrays to create 3 lines on a graph.
> >
> > Any help is absolutley appreciated! Heck I will even name the code and app
> > after you!
> >
> > RS
> >
> >
> >
> >
> > 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
> 
> _______________________________________________
> talk mailing list
> talk at lists.nyphp.org
> http://lists.nyphp.org/mailman/listinfo/talk

-- 
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
            data intensive web and database programming
                http://www.AnalysisAndSolutions.com/
 4015 7th Ave #4, Brooklyn NY 11232  v: 718-854-0335 f: 718-854-0409



More information about the talk mailing list