skolroots 0 Denunciar post Postado Abril 17, 2006 eae galera..to tentando aqui algo simples...tipo...pegar os dados de uma consulta e colocar em um menu supenso...<?$conexao = mysql_connect("localhost", "root", "");mysql_select_db("biblio", $conexao);$sql="SELECT nome FROM aux_categoria";$result = mysql_query($sql,$conexao) or die(mysql_error());$contar = mysql_num_rows($result);$i = 0 ;while ($i < $contar) {$ver = mysql_result($result,$i,"nome");echo "$ver<BR>";$i = $i + 1;}?> usei esse código ae...e tá funcionando...mas qdo tento adapatá ele ao <select> dá tilt....help-metentei fazê assim ó...mas ae aparece '$ver' no option<?$conexao = mysql_connect("localhost", "root", "");mysql_select_db("biblio", $conexao);$sql="SELECT nome FROM aux_categoria";$result = mysql_query($sql,$conexao) or die(mysql_error());$contar = mysql_num_rows($result);$i = 0 ;?><select name="categoria"><?while ($i < $contar) {$ver = mysql_result($result,$i,"nome");echo "<option value='$ver'>'$ver'</option>";$i = $i + 1;}?> </select>se alguém puder dá uma mão ae...blza!vlw Compartilhar este post Link para o post Compartilhar em outros sites
eronventer 2 Denunciar post Postado Abril 17, 2006 cara a sintaxe ta certa testei aki e nenhum problema. na tua tabela aux_categoria tu tem o campo nome? eu fiz exatamente igual soh mudei o nome da banco hehehe <? $conexao = mysql_connect("localhost", "root", ""); mysql_select_db("testes", $conexao); $sql="SELECT nome FROM aux_categoria"; $result = mysql_query($sql,$conexao) or die(mysql_error()); $contar = mysql_num_rows($result); $i = 0 ; ?> <select name="categoria"> <? while ($i < $contar) { $ver = mysql_result($result,$i,"nome"); echo "<option value='$ver'>$ver</option>\n"; $i++; } ?> </select> Compartilhar este post Link para o post Compartilhar em outros sites