ElProgramador Posted April 24, 2013 at 09:46 AM Report #504631 Posted April 24, 2013 at 09:46 AM Boas pessoal. Como posso mostrar todos os dados da tabela que esta na bd sem saber os campos que nel existem? Pois a tabela não tem sempre os mesmo campos. Cumpz
pikax Posted April 24, 2013 at 09:51 AM Report #504633 Posted April 24, 2013 at 09:51 AM primeiro, qual e' a BD que estas a usar? Por muito mais que que estude só aprendo uma coisa, que ainda tenho muita coisa para aprender. A beleza de um código está em decompor problemas complexos em pequenos blocos simples. "learn how to do it manually first, then use the wizzy tool to save time." "Kill the baby, don't be afraid of starting all over again. Fail soon, learn fast."
ElProgramador Posted April 24, 2013 at 09:55 AM Author Report #504634 Posted April 24, 2013 at 09:55 AM Boas Pikax Estou a usar o wamp server. Mysql server do wamp server Cumpx
pikax Posted April 24, 2013 at 09:56 AM Report #504635 Posted April 24, 2013 at 09:56 AM tens aqui a funcao em mysqli http://www.php.net/manual/en/mysqli-result.fetch-field.php Por muito mais que que estude só aprendo uma coisa, que ainda tenho muita coisa para aprender. A beleza de um código está em decompor problemas complexos em pequenos blocos simples. "learn how to do it manually first, then use the wizzy tool to save time." "Kill the baby, don't be afraid of starting all over again. Fail soon, learn fast."
ElProgramador Posted April 24, 2013 at 10:43 AM Author Report #504642 Posted April 24, 2013 at 10:43 AM (edited) $ query = "SELECT nome, SurfaceArea de ORDER BY País Código LIMIT 5" ; if ( $ result = $ mysqli -> query ( $ query )) { / * Obter informações de campo para todas as colunas * / while ( $ finfo = $ result -> fetch_field ()) { printf ( "Nome:% s \ n" , $ finfo -> nome ); printf ( "Tabela:% s \ n" , $ finfo - > mesa ); printf ( "max Len:.% d \ n" , $ finfo -> max_length ); printf ( "Flags:% d \ n" , $ finfo -> bandeiras ), printf ( "Tipo:% d \ n \ n " , $ finfo -> tipo ); } $ result -> Fechar (); } Este é o código que estava no link eu tenho que substituir o nome.... Mas eu so sei uma coluna da minha tabela. Tipo a minha tabela(traducasite) com uma coluna(conteudo). E eu preciso mostrar esta tabela mas mas na sua totalidade. Cumpz Edited April 24, 2013 at 05:21 PM by brunoais geshi
pikax Posted April 24, 2013 at 10:46 AM Report #504643 Posted April 24, 2013 at 10:46 AM qual e' o erro que esta' a dar? qual e' esta funcao? $ result -> Fechar (); Por muito mais que que estude só aprendo uma coisa, que ainda tenho muita coisa para aprender. A beleza de um código está em decompor problemas complexos em pequenos blocos simples. "learn how to do it manually first, then use the wizzy tool to save time." "Kill the baby, don't be afraid of starting all over again. Fail soon, learn fast."
ElProgramador Posted April 24, 2013 at 10:52 AM Author Report #504645 Posted April 24, 2013 at 10:52 AM (edited) $query = "SELECT Name, SurfaceArea from Country ORDER BY Code LIMIT 5"; if ($result = $mysqli->query($query)) { /* Get field information for all columns */ while ($finfo = $result->fetch_field()) { printf("Name: %s\n", $finfo->conteudo); printf("Table: %s\n", $finfo->traducasite); } $result->close(); } /* close connection */ $mysqli->close(); ?> Dame erro no if Edited April 24, 2013 at 05:21 PM by brunoais geshi
pikax Posted April 24, 2013 at 10:54 AM Report #504646 Posted April 24, 2013 at 10:54 AM (edited) Nao existem esses campos.... printf("Name: %s\n", $finfo->conteudo); printf("Table: %s\n", $finfo->traducasite); Parece que o chrome ataca de novo 😄 o codigo que esta' la' no link e' este: <?php $mysqli = new mysqli("localhost", "my_user", "my_password", "world"); /* check connection */ if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } $query = "SELECT Name, SurfaceArea from Country ORDER BY Code LIMIT 5"; if ($result = $mysqli->query($query)) { /* Get field information for all columns */ while ($finfo = $result->fetch_field()) { printf("Name: %s\n", $finfo->name); printf("Table: %s\n", $finfo->table); printf("max. Len: %d\n", $finfo->max_length); printf("Flags: %d\n", $finfo->flags); printf("Type: %d\n\n", $finfo->type); } $result->close(); } /* close connection */ $mysqli->close(); ?> Edited April 24, 2013 at 10:55 AM by pikax Por muito mais que que estude só aprendo uma coisa, que ainda tenho muita coisa para aprender. A beleza de um código está em decompor problemas complexos em pequenos blocos simples. "learn how to do it manually first, then use the wizzy tool to save time." "Kill the baby, don't be afraid of starting all over again. Fail soon, learn fast."
ElProgramador Posted April 24, 2013 at 11:09 AM Author Report #504650 Posted April 24, 2013 at 11:09 AM SIm e agora com esse código o que tenho que alterar visto que so conheço o nome da tabela e o nome de uma coluna?
pikax Posted April 24, 2013 at 11:15 AM Report #504651 Posted April 24, 2013 at 11:15 AM deves ter que alterar a connection e tambem a query Por muito mais que que estude só aprendo uma coisa, que ainda tenho muita coisa para aprender. A beleza de um código está em decompor problemas complexos em pequenos blocos simples. "learn how to do it manually first, then use the wizzy tool to save time." "Kill the baby, don't be afraid of starting all over again. Fail soon, learn fast."
ElProgramador Posted April 24, 2013 at 11:21 AM Author Report #504653 Posted April 24, 2013 at 11:21 AM Sim ja alterei os dados da conexão e também a query. Mesmo assim nao mostra a tabela..
pikax Posted April 24, 2013 at 11:22 AM Report #504654 Posted April 24, 2013 at 11:22 AM Qual e' o output? Por muito mais que que estude só aprendo uma coisa, que ainda tenho muita coisa para aprender. A beleza de um código está em decompor problemas complexos em pequenos blocos simples. "learn how to do it manually first, then use the wizzy tool to save time." "Kill the baby, don't be afraid of starting all over again. Fail soon, learn fast."
ElProgramador Posted April 24, 2013 at 11:26 AM Author Report #504655 Posted April 24, 2013 at 11:26 AM Conteudo e o campo da tabela Traducasite e o nome da tabela. OutPut Name: Conteudo Table:traducaSite max. Len: 10 Flags: 4097 Type:253
pikax Posted April 24, 2013 at 11:27 AM Report #504656 Posted April 24, 2013 at 11:27 AM ta' certo, faz o que e' suposto. agora podes guardar num dicionario e depois fazer o while para ver o resultado da query Por muito mais que que estude só aprendo uma coisa, que ainda tenho muita coisa para aprender. A beleza de um código está em decompor problemas complexos em pequenos blocos simples. "learn how to do it manually first, then use the wizzy tool to save time." "Kill the baby, don't be afraid of starting all over again. Fail soon, learn fast."
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now