Re: foreach with mysql

From: Date: Wed, 14 May 2003 04:18:59 +0000
Subject: Re: foreach with mysql
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-19920@lists.php.net to get a copy of this message
Kyle's example is good, but it lacks in the way of syntax of PHP. Mostly in the line where he is echoing the values... You don't need quotes if the content is a variable... e.g. echo $row; and you should always put quotes around hash names in an array e.g. echo $row['name']; Thanks Brad "Kyle Williamson" <k.williamson@applemore.hants.sch.uk> wrote in message news:3E6AF794@webmail.hants.gov.uk... > Why a foreach? > > while($row = mysql_fetch_array($result)) { > echo "$row[name]"; > } > > >===== Original Message From <s.garriock@rgc.aberdeen.sch.uk> ===== > >Hi > >I am trying to use a FOREACH command to go through a mysql result with 2 > >columns. > >They are ID and name > >I need the name one the ID one is just for referrence. > >Anyone got the syntax for it? > > > >Thanks tons > >From Shaun Garriock > >RGC Webmaster > > > >*** The contents of this message are confidential and are intended for the > addressee only. The views expressed in this message do not necessarily > represent those of Robert Gordon's College. Electronic mail transmission is > not guaranteed to be secure, therefore, Robert Gordon's College does not > accept liability for the contents of this transmission. This message does not > form a legal binding contract. *** > > > > > >-- > >PHP Windows Mailing List (http://www.php.net/) > >To unsubscribe, visit: http://www.php.net/unsub.php > > == > > Kyle Williamson > Solent Educational > > Tel: (023) 80 848319 Fax: (023) 80 848715 >

« previous php.windows (#19920) next »