Re: mysql_fetch_array

From: Date: Wed, 18 Jul 2001 14:24:23 +0000
Subject: Re: mysql_fetch_array
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-8375@lists.php.net to get a copy of this message
So you have all these values stored in $variable_row[id], right? Assuming that's what you're saying, do this: for ($i=0; $i<count($variable_row); $i++) { $temp="variable_".$i; $$temp=$variable_row[$i]; } Now you will have $variable_1, $variable_2 and so forth. I hope I got what you were trying to do. Lemme know if that works. "Andrew.Martin" wrote: > > 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 -- Paul Smith psmith@dostuff.net http://www.dostuff.net

« previous php.windows (#8375) next »