NYCPHP Meetup

NYPHP.org

[nycphp-talk] RE: Best way to read in an array

Chris Bielanski Cbielanski at inta.org
Fri Mar 12 13:57:23 EST 2004


let me modify that a little...

WAS:
array_push($plotdata,
array($row['category'],$row['month1'],$row['month2'],$row['month3']));

SHOULD BE:
array_push($plotdata,
 array('category' => $row['category'],'month1' => $row['month1'], 'month2'
=> $row['month2'], 'month3' =>$row['month3']));

Sorry about that!! :)

~C

> -----Original Message-----
> From: Chris Bielanski [mailto:Cbielanski at inta.org]
> Sent: Friday, March 12, 2004 1:54 PM
> To: 'NYPHP Talk'
> Subject: RE: [nycphp-talk] RE: Best way to read in an array
> 
> 
> do your query, then with the $result...
> 
> while($row = mysql_fetch_assoc($result))
> {
> // this will need to be put into an array if you get multiple 
> rows, so...
> array_push($plotdata,
> array($row['category'],$row['month1'],$row['month2'],$row['month3']));
> }
> Bear in mind that column names are case-senseitive from the 
> query to the
> associative index name. When using select *, the indices in 
> $row will be
> *exactly* as the column names are in the table.
> 
> HTH
> ~Chris
> 
> > -----Original Message-----
> > From: Rafi Sheikh [mailto:Rafi.Sheikh at Ingenix.com]
> > Sent: Friday, March 12, 2004 1:44 PM
> > To: 'talk at lists.nyphp.org'
> > Subject: [nycphp-talk] RE: Best way to read in an array
> > 
> > 
> > Hello List:  I am very new and hoping to get some help in 
> > terms of reading
> > an array (I have tried but failing)
> > 
> > BASIC: apache 1.3.29, PHP 4.3.4, MySQL 4.0.17-nt on WIN2K-Pro
> > 
> > I have data as :
> > category	month1	month2	month3
> > abc		100		99		100
> > xyz		98		99		89
> > 
> > etc...
> > 
> > QUESTION:
> > I need to geteach row in in variable so I could use it in a 
> > line graph or
> > as:
> > 
> > $datax=array(100,99,100)   //to be laid out, I will use 
> > $datax in my graph
> > plot line
> > 
> > There would be 6 rows that I need 6 lines.
> > 
> > I have the table in a table in Mysql
> > 
> > PROBLEM:
> > I have no idea how can I read the table so each row is assigned to a
> > varaible that I oculd use as example above.
> > 
> > I have read and re-read arcticles, but I am missing 
> > things..any help in
> > formulating this block is truly appreciated.
> > 
> > Regards,
> > 
> > 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
> > 
> _______________________________________________
> talk mailing list
> talk at lists.nyphp.org
> http://lists.nyphp.org/mailman/listinfo/talk
> 



More information about the talk mailing list