NYCPHP Meetup

NYPHP.org

[nycphp-talk] creating unique array per row

Henry Ponce henry at beewh.com
Tue Mar 16 06:29:07 EST 2004


You could do something like this

$q = "select * from table_name";
$result = mysql_query($q);

$table_rows = array ();  //array of arrays
$cont = 0;  //counter

while ($row = mysql_fetch_array($result)){
	$table_rows [$cont] = $row;   //adds the array to the array
	$cont++;   //increment the counter
}


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




More information about the talk mailing list