RE: [PHP-WIN] mysql_fetch_array

From: Date: Wed, 18 Jul 2001 14:59:52 +0000
Subject: RE: [PHP-WIN] mysql_fetch_array
Groups: php.windows 
Request: Send a blank email to php-windows+get-8378@lists.php.net to get a copy of this message
Thats it, I used the array solution which means I can directly call the specific variable outside the while loop. thanks again. Andrew -----Original Message----- From: Michael Rudel [mailto:mru@suchtreffer.de] Sent: 18 July 2001 16:15 To: 'Andrew.Martin' Subject: RE: [PHP-WIN] mysql_fetch_array Hi Martin. ... why don't you use an array ?? $variable_row[$row['id']] = $row['description']; So you can access it with: $variable_row[1] // and it gives you the description. OR (to answer you question =8) try this one: $varname = "variable_row".$row['id']; $$varname = $row['description']; Now you can access the vars as you described before. Hope this helps. Greetinx, Mike Michael Rudel - Web-Development, Systemadministration - Besuchen Sie uns am 20. und 21. August 2001 auf der online-marketing-düsseldorf in Halle 1 Stand E 16 _______________________________________________________________ Suchtreffer AG Bleicherstraße 20 D-78467 Konstanz Germany fon: +49-(0)7531-89207-17 fax: +49-(0)7531-89207-13 e-mail: mailto:mru@suchtreffer.de internet: http://www.suchtreffer.de _______________________________________________________________ > -----Original Message----- > From: Andrew.Martin [mailto:Martin.Andrew@kpmg-ct.com] > Sent: Wednesday, July 18, 2001 4:02 PM > To: php-windows@lists.php.net > Subject: [PHP-WIN] mysql_fetch_array > > > I'm using this function to check the value of specific fileds > per row in the > database. > such as.... > $query = "SELECT * FROM $dbn WHERE status = 4"; > $result = mysql_query($query) or die("failed to connect to DB"); > > while ($row = mysql_fetch_array ($result)) { > print "row id = $row[id]"; > print "decription in row = $row[description]"; > } > > this works fine, it checks the DB for values with status = 4 > and prints row > id and row description > > My problem occurs when I want to creat variables based on > these results. > > I would ideally like to create dynamic variables based on > row_id number e.g. > > variable_row[id] = $row[description] > > so later in the dynamically created page I could enter > $variable_1 (1 being > the row[id] value) and the correct value would be selected. > Is there anyway > of doing this? I tried using $$variable etc but no luck. > > Any ideas appriciated. > Andrew > > >

« previous php.windows (#8378) next »