Re: WAHT is my error???

From: Date: Fri, 20 Aug 2004 19:11:32 +0000
Subject: Re: WAHT is my error???
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-194361@lists.php.net to get a copy of this message
"Andre" <andre_caridade@sapo.pt> wrote in message news:php.general-194357@news.php.net... > > Inside of one ARRAY can I make one WHILE > > function tabelas($tabela_tipo){ > $sql = mysql_query("SELECT * FROM ".$tabela_tipo."_credito ORDER BY > ".$tabela_tipo."_ordenar"); > $return = "<select name=\"tabelas\" > class=\"textblack\">\n"; > $tabela_array = array("". > while($registo = mysql_fetch_array($sql)){ > array ("".$registo[0]."", > "".$registo[0]."&nbsp;".$registo[0].""); > }."" > foreach($tabela_array as $subarray) > list($num, $text) = $subarray; > $return .= "<option value=\"$num\" > selected>$text</option>\n"; > } > $return .= "</select>\n"; > return $return; > } > > I guess your loop should look like this: while ($registo = mysql_fetch_array($sql)) { echo '<option value="' . $registo[0] . '">' . $registo[1] . '</option>'; } You can use mysql_fetch_assoc() and then access the values by their column name: $registo['column1'], $registo['column2'] etc. Regards, Torsten Roehr

« previous php.general (#194361) next »