SilvaDias Posted April 6, 2014 Report Share Posted April 6, 2014 Boas, Sou novo em php e estou a encontrar com bastantes dificuldades, preciso de uma ajuda 馃檪 ; Estou a fazer um c贸digo em php para ir buscar informa莽玫es sobre uma tabela da base de dados e imprimir num website, O c贸digo 茅 o seguinte: <?php require_once('connections/config.php'); $qry = mysql_query("SELECT idConta , idUtilizador , Banco , TipoConta FROM conta WHERE idUtilizador = '$id'"); $num_fields = mysql_num_fields($qry); $fields=array(); for($i = 0;$i<$num_fields; $i++) { $fields[] = mysql_field_name($qry,$i); } $table = '<table class="table_contas"><tr>'; for($i = 0;$i < $num_fields; $i++){ $table .= '<th>'.$fields[$i].'</th>'; } $table .= '<tbody>'; while($r = mysql_fetch_array($qry)){ $table .= '<tr class="tc_tr">'; for($i = 0;$i < $num_fields; $i++){ $table .= '<td>'.$r[$fields[$i]].'</td>'; } $table .= '</tr>'; } $table .= '</tbody></table>'; echo $table; ?> O c贸digo funciona perfeitamente. Mas o que eu queria fazer era pegar no id da linha da tabela da base de dados (neste caso o 'idConta') e atribuir esse id 谩 tag tr... Alguem pode ajudar? Link to comment Share on other sites More sharing options...
Devexz Posted April 6, 2014 Report Share Posted April 6, 2014 s贸 tens de aceder ao array retornado da query $table .= '<tr class="tc_tr" id = " '.$r["idConta"].' ">'; Contador de calorias: caloriaspordia.com Link to comment Share on other sites More sharing options...
SilvaDias Posted April 6, 2014 Author Report Share Posted April 6, 2014 Funcionou, muito obrigado 馃檪 Link to comment Share on other sites More sharing options...
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