Ir para conteúdo
Fórum Script Brasil

Bootstrap

Membros
  • Total de itens

    3
  • Registro em

  • Última visita

Sobre Bootstrap

Bootstrap's Achievements

0

Reputação

  1. Oi, pessoal, O usuário mikosiko do forum http://forums.devnetwork.net me passou o código que resolve perfeitamente o problema. Estou postando aqui para caso algum dia alguém precise. // Example $heading_column = '<whatever is the name of your heading column>'; $last_heading = null; while($row = your_fetch_assoc_statement){ // detect a change in the heading value and output the new heading if($last_heading != $row[$heading_column]){ // detect if it is not the first heading - close out the previous section if($last_heading != null){ // your code to close the previous section (table, div, etc)... echo "close section<br />"; } // output the new heading here... echo "new section title - {$row[$heading_column]}<br />"; // save the new heading as the last_heading $last_heading = $row[$heading_column]; } // output the actual data here... echo "data - {$row['your_data']}<br />"; } // if there was any output - close out the last section if($last_heading != null){ // your code to close the previous section (table, div, etc)... echo "close section<br ?>"; }
  2. ESerra, muito obrigado pela ajuda e atenção com meu problema. Tentei implementar a sua solução no meu problema, mas fiquei em dúvida: Minha necessidade é testar o registro atual com o próximo registro. Mas na sua implementação o teste está sendo feito entre o registro atual e o anterior. Não entendi como fazer essa parte funcionar.
  3. Oi, pessoal, Eu tenho esse código em PHP $sql = "Select * from..." $result = mysql_query($sql,$connection); while ($row = mysql_fetch_array($result)) { ...... } O que eu estou precisando é conseguir ler o próximo registro dentro do laço para fazer a comparação com o registro atual. Por exemplo: while ($row = mysql_fetch_array($result)) { ...... if (ID DO PRÓXIMO RECORD != ID DO ATUAL RECORD) { faça-alguma-coisa } } O resultado que eu estou buscando é algo como: Produto 1 Produto 1 <quebra de linha ou qualquer outra ação> Produto 2 Produto 2 Produto 2 Produto 2 <quebra de linha ou qualquer outra ação> Eu cheguei bem próximo da solução usando o código abaixo que encontrei na net, o único problema é que o último registro da query é sempre ignorado (não entra no while): $current_row=mysql_fetch_array($result); //read $current_row while ($next_row = mysql_fetch_array($result)) { //read $next_row ...... if ($current_row['id']!=$next_row['id']) { //compare it ..... ..... } $current_row=$next_row; //$next_row become current_row on next step } travei forte nesse problema e agradeço qualquer ajuda.
×
×
  • Criar Novo...